@opengeoweb/taf 2.13.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { TextField, Grid, Box, Button, IconButton, Tooltip, Chip, Typography, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
3
+ import { TextField, Grid, Box, Button, IconButton, Tooltip, Chip, Typography, FormLabel, Switch, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
4
4
  import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
5
5
  import { ReactSortable, Sortable } from 'react-sortablejs';
6
- import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
7
- import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, isAxiosError, getAxiosErrorMessage, AlertBanner, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
8
6
  import { isEqual } from 'lodash';
7
+ import { useAuthenticationContext } from '@opengeoweb/authentication';
8
+ import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
9
+ import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, Avatar, getInitials, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, AlertBanner, getErrorMessage as getErrorMessage$1, getWarningMessage, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
9
10
  import moment from 'moment';
10
- import { Add, Delete, Close, DragHandle as DragHandle$1, ThumbsUp, Clock, Cancel, Edit, Success, Export, ListItem } from '@opengeoweb/theme';
11
+ import { Add, Delete, Close, DragHandle as DragHandle$1, ThumbsUp, Clock, Cancel, Edit, Success, Export, ListItem, Cached } from '@opengeoweb/theme';
11
12
  import makeStyles from '@mui/styles/makeStyles';
12
13
  import ReactDOM from 'react-dom';
13
- import { useApiContext, useApi, createApiInstance, ApiProvider } from '@opengeoweb/api';
14
+ import { useApiContext, createApiInstance, ApiProvider } from '@opengeoweb/api';
14
15
  import LinearProgress from '@mui/material/LinearProgress';
15
16
  import Box$1 from '@mui/material/Box';
16
17
 
@@ -3832,7 +3833,12 @@ var IssuesPane = function IssuesPane(_ref3) {
3832
3833
  fontSize: '4rem'
3833
3834
  },
3834
3835
  "data-testid": "zeroIssuesImage"
3835
- }, /*#__PURE__*/React.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3836
+ }, /*#__PURE__*/React.createElement(ThumbsUp, {
3837
+ sx: {
3838
+ height: '69px',
3839
+ width: '58px'
3840
+ }
3841
+ })), errorList.length > 0 && errorList.map(function (error, index) {
3836
3842
  return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
3837
3843
  , {
3838
3844
  // eslint-disable-next-line react/no-array-index-key
@@ -3922,9 +3928,75 @@ var TafModuleProvider = function TafModuleProvider(_ref2) {
3922
3928
  }, children);
3923
3929
  };
3924
3930
 
3931
+ /* *
3932
+ * Licensed under the Apache License, Version 2.0 (the "License");
3933
+ * you may not use this file except in compliance with the License.
3934
+ * You may obtain a copy of the License at
3935
+ *
3936
+ * http://www.apache.org/licenses/LICENSE-2.0
3937
+ *
3938
+ * Unless required by applicable law or agreed to in writing, software
3939
+ * distributed under the License is distributed on an "AS IS" BASIS,
3940
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3941
+ * See the License for the specific language governing permissions and
3942
+ * limitations under the License.
3943
+ *
3944
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3945
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3946
+ * */
3947
+ var styles = {
3948
+ label: {
3949
+ color: 'geowebColors.buttons.tertiary.default.color',
3950
+ opacity: 1,
3951
+ fontSize: '12px',
3952
+ fontWeight: 500
3953
+ }
3954
+ };
3955
+
3956
+ var SwitchButton = function SwitchButton(props) {
3957
+ return /*#__PURE__*/React.createElement(Tooltip, {
3958
+ title: "Switch mode"
3959
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormLabel, {
3960
+ sx: styles.label
3961
+ }, "Viewer"), /*#__PURE__*/React.createElement(Switch, Object.assign({
3962
+ "data-testid": "switchMode"
3963
+ }, props)), /*#__PURE__*/React.createElement(FormLabel, {
3964
+ sx: styles.label
3965
+ }, "Editor")));
3966
+ };
3967
+
3968
+ /* *
3969
+ * Licensed under the Apache License, Version 2.0 (the "License");
3970
+ * you may not use this file except in compliance with the License.
3971
+ * You may obtain a copy of the License at
3972
+ *
3973
+ * http://www.apache.org/licenses/LICENSE-2.0
3974
+ *
3975
+ * Unless required by applicable law or agreed to in writing, software
3976
+ * distributed under the License is distributed on an "AS IS" BASIS,
3977
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3978
+ * See the License for the specific language governing permissions and
3979
+ * limitations under the License.
3980
+ *
3981
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3982
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3983
+ * */
3984
+
3985
+ var TafAvatar = function TafAvatar(_ref) {
3986
+ var editor = _ref.editor,
3987
+ _ref$tooltipPlacement = _ref.tooltipPlacement,
3988
+ tooltipPlacement = _ref$tooltipPlacement === void 0 ? 'bottom' : _ref$tooltipPlacement;
3989
+ return /*#__PURE__*/React.createElement(Tooltip, {
3990
+ title: "Editor: ".concat(editor),
3991
+ placement: tooltipPlacement
3992
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Avatar, {
3993
+ size: "small"
3994
+ }, getInitials(editor))));
3995
+ };
3996
+
3925
3997
  var noop = function noop() {};
3926
3998
 
3927
- var TafForm = function TafForm(_ref) {
3999
+ var TafForm = /*#__PURE__*/React__default.memo(function (_ref) {
3928
4000
  var tafFromBackend = _ref.tafFromBackend,
3929
4001
  _ref$onFormAction = _ref.onFormAction,
3930
4002
  onFormAction = _ref$onFormAction === void 0 ? function () {
@@ -3941,9 +4013,19 @@ var TafForm = function TafForm(_ref) {
3941
4013
  _ref$setIsDisabled = _ref.setIsDisabled,
3942
4014
  setIsDisabled = _ref$setIsDisabled === void 0 ? function () {
3943
4015
  return null;
3944
- } : _ref$setIsDisabled;
3945
- var originalTaf = tafFromBackend.taf;
3946
- var isDefaultDisabled = getIsFormDefaultDisabled(tafFromBackend.taf.status);
4016
+ } : _ref$setIsDisabled,
4017
+ _ref$onSwitchEditor = _ref.onSwitchEditor,
4018
+ onSwitchEditor = _ref$onSwitchEditor === void 0 ? function () {
4019
+ return null;
4020
+ } : _ref$onSwitchEditor;
4021
+ var originalTaf = tafFromBackend.taf,
4022
+ editor = tafFromBackend.editor;
4023
+
4024
+ var _useAuthenticationCon = useAuthenticationContext(),
4025
+ auth = _useAuthenticationCon.auth;
4026
+
4027
+ var isEditor = editor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
4028
+ var isDefaultDisabled = getIsFormDefaultDisabled(originalTaf.status);
3947
4029
  var confirmDialog = useConfirmationDialog();
3948
4030
 
3949
4031
  var _useDraftFormHelpers = useDraftFormHelpers(true),
@@ -4034,19 +4116,106 @@ var TafForm = function TafForm(_ref) {
4034
4116
  var resetFormValues = function resetFormValues() {
4035
4117
  var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
4036
4118
  var shouldAddEmptyChangGroup = arguments.length > 1 ? arguments[1] : undefined;
4037
- var newTaf = prepareTafValues(tafFromBackend.taf, action, shouldAddEmptyChangGroup);
4119
+ var newTaf = prepareTafValues(originalTaf, action, shouldAddEmptyChangGroup);
4038
4120
  reset(newTaf);
4039
4121
  };
4040
4122
 
4041
4123
  var resetForm = function resetForm() {
4042
4124
  var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
4043
4125
  var resetDisabled = arguments.length > 1 ? arguments[1] : undefined;
4044
- var shouldAddEmptyChangGroup = !(tafFromBackend.taf && tafFromBackend.taf.changeGroups) && !resetDisabled;
4126
+ var shouldAddEmptyChangGroup = !(originalTaf && originalTaf.changeGroups) && !resetDisabled;
4045
4127
  resetFormValues(action, shouldAddEmptyChangGroup);
4046
4128
  setIsDisabled(resetDisabled);
4047
4129
  setTafAction(action);
4048
4130
  };
4049
4131
 
4132
+ var setIsEditor = function setIsEditor(checked) {
4133
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4134
+ var editor, didSucceed;
4135
+ return regeneratorRuntime.wrap(function _callee$(_context) {
4136
+ while (1) {
4137
+ switch (_context.prev = _context.next) {
4138
+ case 0:
4139
+ editor = checked ? auth === null || auth === void 0 ? void 0 : auth.username : '';
4140
+
4141
+ if (!(editor === tafFromBackend.editor)) {
4142
+ _context.next = 3;
4143
+ break;
4144
+ }
4145
+
4146
+ return _context.abrupt("return", true);
4147
+
4148
+ case 3:
4149
+ if (!(tafFromBackend.editor !== '' && tafFromBackend.editor !== null && tafFromBackend.editor !== (auth === null || auth === void 0 ? void 0 : auth.username))) {
4150
+ _context.next = 6;
4151
+ break;
4152
+ }
4153
+
4154
+ _context.next = 6;
4155
+ return confirmDialog({
4156
+ title: 'Switch to editor mode',
4157
+ description: 'This TAF is already in edit mode and important information could get lost in the switching process.',
4158
+ confirmLabel: 'Edit mode'
4159
+ });
4160
+
4161
+ case 6:
4162
+ _context.next = 8;
4163
+ return onSwitchEditor(Object.assign(Object.assign({}, tafFromBackend), {
4164
+ editor: editor
4165
+ }));
4166
+
4167
+ case 8:
4168
+ didSucceed = _context.sent;
4169
+ return _context.abrupt("return", didSucceed);
4170
+
4171
+ case 10:
4172
+ case "end":
4173
+ return _context.stop();
4174
+ }
4175
+ }
4176
+ }, _callee);
4177
+ }));
4178
+ };
4179
+
4180
+ var onSwitchMode = function onSwitchMode(event) {
4181
+ var checked = event.target.checked;
4182
+
4183
+ if (!checked && isFormDirty) {
4184
+ confirmDialog({
4185
+ title: 'Whoops',
4186
+ description: 'Are you sure you want to switch to viewer mode? Your unsaved changes will be lost.',
4187
+ confirmLabel: 'Switch mode'
4188
+ }).then(function () {
4189
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
4190
+ var didSucceed;
4191
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
4192
+ while (1) {
4193
+ switch (_context2.prev = _context2.next) {
4194
+ case 0:
4195
+ _context2.next = 2;
4196
+ return setIsEditor(checked);
4197
+
4198
+ case 2:
4199
+ didSucceed = _context2.sent;
4200
+
4201
+ if (didSucceed) {
4202
+ resetForm(undefined, isDefaultDisabled);
4203
+ resetTAC();
4204
+ }
4205
+
4206
+ case 4:
4207
+ case "end":
4208
+ return _context2.stop();
4209
+ }
4210
+ }
4211
+ }, _callee2);
4212
+ }));
4213
+ });
4214
+ } else {
4215
+ setIsEditor(checked);
4216
+ }
4217
+ };
4218
+
4050
4219
  var onTafEditModeButtonPress = function onTafEditModeButtonPress(action) {
4051
4220
  switch (action) {
4052
4221
  case 'DRAFT':
@@ -4076,21 +4245,21 @@ var TafForm = function TafForm(_ref) {
4076
4245
  case 'PUBLISH':
4077
4246
  toggleIsDraft(false);
4078
4247
  handleSubmit(function (data) {
4079
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4248
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
4080
4249
  var didSucceed;
4081
- return regeneratorRuntime.wrap(function _callee$(_context) {
4250
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
4082
4251
  while (1) {
4083
- switch (_context.prev = _context.next) {
4252
+ switch (_context3.prev = _context3.next) {
4084
4253
  case 0:
4085
- _context.next = 2;
4254
+ _context3.next = 2;
4086
4255
  return showConfirmDialog(action);
4087
4256
 
4088
4257
  case 2:
4089
- _context.next = 4;
4258
+ _context3.next = 4;
4090
4259
  return onFormAction(action, convertTafValuesToObject(data));
4091
4260
 
4092
4261
  case 4:
4093
- didSucceed = _context.sent;
4262
+ didSucceed = _context3.sent;
4094
4263
 
4095
4264
  if (didSucceed) {
4096
4265
  setIsDisabled(true);
@@ -4100,10 +4269,10 @@ var TafForm = function TafForm(_ref) {
4100
4269
 
4101
4270
  case 6:
4102
4271
  case "end":
4103
- return _context.stop();
4272
+ return _context3.stop();
4104
4273
  }
4105
4274
  }
4106
- }, _callee);
4275
+ }, _callee3);
4107
4276
  }));
4108
4277
  })();
4109
4278
  break;
@@ -4118,7 +4287,21 @@ var TafForm = function TafForm(_ref) {
4118
4287
  switch (action) {
4119
4288
  case 'CANCEL':
4120
4289
  showConfirmDialog(action).then(function () {
4121
- onFormAction(action, convertTafValuesToObject(prepareTafValues(tafFromBackend.taf, action)));
4290
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
4291
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
4292
+ while (1) {
4293
+ switch (_context4.prev = _context4.next) {
4294
+ case 0:
4295
+ _context4.next = 2;
4296
+ return onFormAction(action, convertTafValuesToObject(prepareTafValues(originalTaf, action)));
4297
+
4298
+ case 2:
4299
+ case "end":
4300
+ return _context4.stop();
4301
+ }
4302
+ }
4303
+ }, _callee4);
4304
+ }));
4122
4305
  });
4123
4306
  break;
4124
4307
 
@@ -4215,8 +4398,8 @@ var TafForm = function TafForm(_ref) {
4215
4398
  setShouldValidate = _React$useState4[1];
4216
4399
 
4217
4400
  React__default.useEffect(function () {
4218
- setIsDisabled(isDefaultDisabled);
4219
- var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
4401
+ setIsDisabled(!isEditor || isDefaultDisabled);
4402
+ var defaultValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled && !originalTaf.changeGroups); // set initial form values
4220
4403
 
4221
4404
  reset(defaultValues); // set validate flag to validate after the values have been set
4222
4405
 
@@ -4246,23 +4429,54 @@ var TafForm = function TafForm(_ref) {
4246
4429
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
4247
4430
  }, []);
4248
4431
  React__default.useEffect(function () {
4249
- var newValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set new form values when tafFromBackend changed
4432
+ var newValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled && !originalTaf.changeGroups); // set new form values when taf values changed
4433
+
4434
+ reset(newValues); // reset TAC when taf values changed
4250
4435
 
4251
- reset(newValues); // eslint-disable-next-line react-hooks/exhaustive-deps
4252
- }, [tafFromBackend]);
4436
+ resetTAC(); // eslint-disable-next-line react-hooks/exhaustive-deps
4437
+ }, [originalTaf]);
4438
+ React__default.useEffect(function () {
4439
+ // update disabled state when editor changed
4440
+ setIsDisabled(!isEditor || isDefaultDisabled); // eslint-disable-next-line react-hooks/exhaustive-deps
4441
+ }, [editor]);
4253
4442
  React__default.useEffect(function () {
4254
4443
  if (shouldValidate && !isDisabled) {
4255
- // trigger validation on all changegroup validity times after initial load since they could be outside the new validity period
4256
- var _tafFromBackend$taf$c = tafFromBackend.taf.changeGroups,
4257
- changeGroups = _tafFromBackend$taf$c === void 0 ? [] : _tafFromBackend$taf$c;
4444
+ // trigger validation on all changegroup validity times after form is enabled since they could be outside the new validity period
4445
+ var _originalTaf$changeGr = originalTaf.changeGroups,
4446
+ changeGroups = _originalTaf$changeGr === void 0 ? [] : _originalTaf$changeGr;
4258
4447
  var validFields = changeGroups.map(function (_field, index) {
4259
4448
  return "changeGroups[".concat(index, "].valid");
4260
4449
  });
4261
4450
  trigger(validFields);
4262
4451
  } // eslint-disable-next-line react-hooks/exhaustive-deps
4263
4452
 
4264
- }, [shouldValidate]);
4265
- return /*#__PURE__*/React__default.createElement("form", {
4453
+ }, [shouldValidate, isDisabled]);
4454
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
4455
+ sx: {
4456
+ display: 'flex',
4457
+ flexDirection: 'row',
4458
+ alignItems: 'center',
4459
+ position: 'absolute',
4460
+ top: {
4461
+ xs: '20px',
4462
+ sm: '0px'
4463
+ },
4464
+ right: {
4465
+ xs: 'calc(50% - 70px)',
4466
+ sm: '8px'
4467
+ }
4468
+ }
4469
+ }, /*#__PURE__*/React__default.createElement(SwitchButton, {
4470
+ checked: isEditor,
4471
+ onChange: onSwitchMode
4472
+ }), /*#__PURE__*/React__default.createElement(Box, {
4473
+ sx: {
4474
+ width: '16px',
4475
+ marginLeft: 1
4476
+ }
4477
+ }, editor && /*#__PURE__*/React__default.createElement(TafAvatar, {
4478
+ editor: editor
4479
+ }))), /*#__PURE__*/React__default.createElement("form", {
4266
4480
  "data-testid": "taf-form",
4267
4481
  onSubmit: handleSubmit(onSubmit),
4268
4482
  onBlur: onFormBlur
@@ -4328,7 +4542,7 @@ var TafForm = function TafForm(_ref) {
4328
4542
  index: index
4329
4543
  })
4330
4544
  });
4331
- })), !isDisabled && /*#__PURE__*/React__default.createElement(Grid, {
4545
+ })), !isDisabled && isEditor && /*#__PURE__*/React__default.createElement(Grid, {
4332
4546
  container: true,
4333
4547
  justifyContent: "space-between",
4334
4548
  alignItems: "center",
@@ -4342,7 +4556,7 @@ var TafForm = function TafForm(_ref) {
4342
4556
  errors: errors,
4343
4557
  isIssuesPaneOpen: isIssuesPaneOpen,
4344
4558
  setIsIssuesPaneOpen: setIsIssuesPaneOpen
4345
- }))), /*#__PURE__*/React__default.createElement(TafFormButtons, {
4559
+ }))), isEditor && /*#__PURE__*/React__default.createElement(TafFormButtons, {
4346
4560
  isFormDisabled: isDisabled,
4347
4561
  tafAction: tafAction,
4348
4562
  canBe: tafFromBackend.canbe,
@@ -4353,8 +4567,12 @@ var TafForm = function TafForm(_ref) {
4353
4567
  name: field,
4354
4568
  key: field
4355
4569
  });
4356
- }), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null));
4357
- };
4570
+ }), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null)));
4571
+ }, function (prevProps, nextProps) {
4572
+ // prevent re-render
4573
+ return !nextProps.isDisabled && prevProps.tafFromBackend !== nextProps.tafFromBackend && // if editor changed it should rerender
4574
+ prevProps.tafFromBackend.editor === nextProps.tafFromBackend.editor;
4575
+ });
4358
4576
 
4359
4577
  /* *
4360
4578
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4406,14 +4624,16 @@ var TabPanel = function TabPanel(_a) {
4406
4624
  * */
4407
4625
 
4408
4626
  var TafHeader = function TafHeader(_ref) {
4409
- var title = _ref.title;
4627
+ var title = _ref.title,
4628
+ _ref$sx = _ref.sx,
4629
+ sx = _ref$sx === void 0 ? {} : _ref$sx;
4410
4630
  return /*#__PURE__*/React__default.createElement(Typography, {
4411
- sx: {
4631
+ sx: Object.assign({
4412
4632
  textAlign: 'center',
4413
4633
  fontWeight: 500,
4414
4634
  paddingTop: '6px',
4415
4635
  textTransform: 'capitalize'
4416
- }
4636
+ }, sx)
4417
4637
  }, title);
4418
4638
  };
4419
4639
 
@@ -4943,7 +5163,7 @@ var TacOverviewMobile = function TacOverviewMobile(_ref) {
4943
5163
  },
4944
5164
  position: 'absolute',
4945
5165
  right: '8px',
4946
- top: '30px'
5166
+ top: '48px'
4947
5167
  }
4948
5168
  }, /*#__PURE__*/React.createElement(ListItem, null)), /*#__PURE__*/React.createElement(Dialog, {
4949
5169
  open: isOpen,
@@ -5073,7 +5293,8 @@ var LocationTabs = function LocationTabs(_ref) {
5073
5293
  paddingTop: '32px'
5074
5294
  }
5075
5295
  }, tafList.map(function (_ref2, index) {
5076
- var taf = _ref2.taf;
5296
+ var taf = _ref2.taf,
5297
+ editor = _ref2.editor;
5077
5298
  return /*#__PURE__*/React.createElement(MenuItem, {
5078
5299
  key: taf.uuid,
5079
5300
  selected: index === activeIndex,
@@ -5098,8 +5319,18 @@ var LocationTabs = function LocationTabs(_ref) {
5098
5319
  onClick: function onClick() {
5099
5320
  return onChangeTab(index);
5100
5321
  }
5101
- }, /*#__PURE__*/React.createElement(Box$1, {
5322
+ }, editor && /*#__PURE__*/React.createElement(Box$1, {
5323
+ sx: {
5324
+ position: 'absolute',
5325
+ top: '4px',
5326
+ left: '8px'
5327
+ }
5328
+ }, /*#__PURE__*/React.createElement(TafAvatar, {
5329
+ editor: editor,
5330
+ tooltipPlacement: "right"
5331
+ })), /*#__PURE__*/React.createElement(Box$1, {
5102
5332
  component: "span",
5333
+ "data-testid": "taf-location",
5103
5334
  sx: {
5104
5335
  fontSize: '12px',
5105
5336
  fontWeight: '500',
@@ -5173,15 +5404,29 @@ var fromActionToStatus = function fromActionToStatus(tafAction) {
5173
5404
  return 'NEW';
5174
5405
  }
5175
5406
  };
5407
+ var isWarning = function isWarning(error) {
5408
+ return (error === null || error === void 0 ? void 0 : error.type) === 'WARNING';
5409
+ };
5176
5410
 
5177
5411
  var parseErrorMessage = function parseErrorMessage(error, params) {
5412
+ var message = getErrorMessage$1(error);
5413
+ var warningMessage = getWarningMessage(error);
5414
+
5415
+ if (warningMessage) {
5416
+ return {
5417
+ type: 'WARNING',
5418
+ title: warningMessage
5419
+ };
5420
+ }
5421
+
5178
5422
  return params.changeStatusTo === 'CANCELLED' ? {
5179
5423
  type: 'CANCELLED',
5180
- title: 'Cancelling this TAF failed, please try again'
5424
+ title: 'Cancelling this TAF failed, please try again',
5425
+ message: message
5181
5426
  } : {
5182
5427
  type: 'SERVER',
5183
5428
  title: 'An error has occurred while saving, please try again',
5184
- message: isAxiosError(error) ? getAxiosErrorMessage(error) : error.message
5429
+ message: message
5185
5430
  };
5186
5431
  };
5187
5432
 
@@ -5272,6 +5517,10 @@ var TafPanel = function TafPanel(_ref) {
5272
5517
  postTaf = _ref$postTaf === void 0 ? function () {
5273
5518
  return null;
5274
5519
  } : _ref$postTaf,
5520
+ _ref$patchTaf = _ref.patchTaf,
5521
+ patchTaf = _ref$patchTaf === void 0 ? function () {
5522
+ return null;
5523
+ } : _ref$patchTaf,
5275
5524
  _ref$isIssuesPaneOpen = _ref.isIssuesPaneOpen,
5276
5525
  isIssuesPaneOpen = _ref$isIssuesPaneOpen === void 0 ? false : _ref$isIssuesPaneOpen,
5277
5526
  _ref$setIsIssuesPaneO = _ref.setIsIssuesPaneOpen,
@@ -5285,6 +5534,7 @@ var TafPanel = function TafPanel(_ref) {
5285
5534
  return null;
5286
5535
  } : _ref$setIsFormDisable,
5287
5536
  error = _ref.error;
5537
+ var severity = isWarning(error) ? 'warning' : 'error';
5288
5538
 
5289
5539
  var onTafAction = function onTafAction(action, taf) {
5290
5540
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
@@ -5333,7 +5583,10 @@ var TafPanel = function TafPanel(_ref) {
5333
5583
  index: index,
5334
5584
  "data-testid": "taf-panel".concat(activeTafIndex === index ? '-active' : '')
5335
5585
  }, /*#__PURE__*/React__default.createElement(TafHeader, {
5336
- title: getTafStatusLabel(tafFromBackend.taf.status)
5586
+ title: getTafStatusLabel(tafFromBackend.taf.status),
5587
+ sx: {
5588
+ marginBottom: '4px'
5589
+ }
5337
5590
  }), isLoading && /*#__PURE__*/React__default.createElement(Spinner, {
5338
5591
  "data-testid": "taf-loading",
5339
5592
  sx: {
@@ -5342,7 +5595,7 @@ var TafPanel = function TafPanel(_ref) {
5342
5595
  color: 'geowebColors.backdrops.white.fill'
5343
5596
  }
5344
5597
  }), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
5345
- severity: "error",
5598
+ severity: severity,
5346
5599
  title: error.title,
5347
5600
  info: error.message,
5348
5601
  dataTestId: "taf-error",
@@ -5358,7 +5611,8 @@ var TafPanel = function TafPanel(_ref) {
5358
5611
  isIssuesPaneOpen: isIssuesPaneOpen,
5359
5612
  setIsIssuesPaneOpen: setIsIssuesPaneOpen,
5360
5613
  isDisabled: isFormDisabled,
5361
- setIsDisabled: setIsFormDisabled
5614
+ setIsDisabled: setIsFormDisabled,
5615
+ onSwitchEditor: patchTaf
5362
5616
  })));
5363
5617
  };
5364
5618
 
@@ -5389,6 +5643,57 @@ var IssuesPaneWrapper = function IssuesPaneWrapper(props) {
5389
5643
  }, props));
5390
5644
  };
5391
5645
 
5646
+ /* *
5647
+ * Licensed under the Apache License, Version 2.0 (the "License");
5648
+ * you may not use this file except in compliance with the License.
5649
+ * You may obtain a copy of the License at
5650
+ *
5651
+ * http://www.apache.org/licenses/LICENSE-2.0
5652
+ *
5653
+ * Unless required by applicable law or agreed to in writing, software
5654
+ * distributed under the License is distributed on an "AS IS" BASIS,
5655
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5656
+ * See the License for the specific language governing permissions and
5657
+ * limitations under the License.
5658
+ *
5659
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5660
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
5661
+ * */
5662
+ var getLastUpdateTitle = function getLastUpdateTitle(time) {
5663
+ return "Last updated ".concat(time);
5664
+ };
5665
+
5666
+ var LastUpdateTime = function LastUpdateTime(_ref) {
5667
+ var _ref$onUpdateTaf = _ref.onUpdateTaf,
5668
+ onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
5669
+ lastUpdateTime = _ref.lastUpdateTime;
5670
+ return /*#__PURE__*/React__default.createElement(Box, {
5671
+ sx: {
5672
+ display: 'flex',
5673
+ alignItems: 'center',
5674
+ height: '100%',
5675
+ justifyContent: 'flex-end'
5676
+ }
5677
+ }, /*#__PURE__*/React__default.createElement(Typography, {
5678
+ sx: {
5679
+ color: 'geowebColors.captions.captionStatus.rgba',
5680
+ fontSize: '10px',
5681
+ lineHeight: '1.6',
5682
+ letterSpacing: '0.33px'
5683
+ },
5684
+ "data-testid": "lastupdated-time"
5685
+ }, getLastUpdateTitle(lastUpdateTime)), /*#__PURE__*/React__default.createElement(Tooltip, {
5686
+ title: "Click to refresh"
5687
+ }, /*#__PURE__*/React__default.createElement(ToolButton, {
5688
+ "data-testid": "updateTafBtn",
5689
+ onClick: onUpdateTaf,
5690
+ sx: {
5691
+ marginRight: 1,
5692
+ marginLeft: 1
5693
+ }
5694
+ }, /*#__PURE__*/React__default.createElement(Cached, null))));
5695
+ };
5696
+
5392
5697
  var CONFIRM_DIALOG_OPTIONS = {
5393
5698
  title: 'Whoops',
5394
5699
  description: "It's not possible to autosave this TAF due to the presence of issue(s). Are you sure you want to close this TAF? Any changes made will be lost.",
@@ -5398,8 +5703,9 @@ var CONFIRM_DIALOG_OPTIONS = {
5398
5703
  var TafLayout = function TafLayout(_ref) {
5399
5704
  var _ref$tafList = _ref.tafList,
5400
5705
  tafList = _ref$tafList === void 0 ? [] : _ref$tafList,
5401
- _ref$onPostTaf = _ref.onPostTaf,
5402
- onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
5706
+ _ref$onUpdateTaf = _ref.onUpdateTaf,
5707
+ onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
5708
+ lastUpdateTime = _ref.lastUpdateTime;
5403
5709
 
5404
5710
  var _useApiContext = useApiContext(),
5405
5711
  api = _useApiContext.api;
@@ -5415,8 +5721,11 @@ var TafLayout = function TafLayout(_ref) {
5415
5721
  var _usePostTafRequest = usePostTafRequest(api.postTaf),
5416
5722
  isLoading = _usePostTafRequest.isLoading,
5417
5723
  postTafRequest = _usePostTafRequest.doRequest,
5418
- error = _usePostTafRequest.error,
5419
- setError = _usePostTafRequest.setError;
5724
+ postError = _usePostTafRequest.error;
5725
+
5726
+ var _usePostTafRequest2 = usePostTafRequest(api.patchTaf),
5727
+ patchTafRequest = _usePostTafRequest2.doRequest,
5728
+ patchError = _usePostTafRequest2.error;
5420
5729
 
5421
5730
  var _useTafModuleContext = useTafModuleContext(),
5422
5731
  onValidateForm = _useTafModuleContext.onValidateForm,
@@ -5455,47 +5764,96 @@ var TafLayout = function TafLayout(_ref) {
5455
5764
  isFormDisabled = _React$useState10[0],
5456
5765
  setIsFormDisabled = _React$useState10[1];
5457
5766
 
5767
+ var _React$useState11 = React__default.useState(),
5768
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
5769
+ error = _React$useState12[0],
5770
+ setError = _React$useState12[1];
5771
+
5458
5772
  var postTaf = function postTaf(data) {
5459
5773
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
5460
5774
  return regeneratorRuntime.wrap(function _callee$(_context) {
5461
5775
  while (1) {
5462
5776
  switch (_context.prev = _context.next) {
5463
5777
  case 0:
5464
- _context.next = 2;
5778
+ _context.prev = 0;
5779
+ setError(null);
5780
+ _context.next = 4;
5465
5781
  return postTafRequest(data);
5466
5782
 
5467
- case 2:
5783
+ case 4:
5468
5784
  // callback
5469
- onPostTaf();
5785
+ onUpdateTaf();
5786
+ _context.next = 11;
5787
+ break;
5470
5788
 
5471
- case 3:
5789
+ case 7:
5790
+ _context.prev = 7;
5791
+ _context.t0 = _context["catch"](0);
5792
+
5793
+ if (isWarning(_context.t0)) {
5794
+ onUpdateTaf();
5795
+ }
5796
+
5797
+ throw _context.t0;
5798
+
5799
+ case 11:
5472
5800
  case "end":
5473
5801
  return _context.stop();
5474
5802
  }
5475
5803
  }
5476
- }, _callee);
5804
+ }, _callee, null, [[0, 7]]);
5477
5805
  }));
5478
5806
  };
5479
5807
 
5480
- function onChangeTab(action, value) {
5481
- return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5482
- var taf;
5808
+ var patchTaf = function patchTaf(data) {
5809
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5483
5810
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
5484
5811
  while (1) {
5485
5812
  switch (_context2.prev = _context2.next) {
5813
+ case 0:
5814
+ _context2.prev = 0;
5815
+ setError(null);
5816
+ _context2.next = 4;
5817
+ return patchTafRequest(data);
5818
+
5819
+ case 4:
5820
+ // callback
5821
+ onUpdateTaf();
5822
+ return _context2.abrupt("return", true);
5823
+
5824
+ case 8:
5825
+ _context2.prev = 8;
5826
+ _context2.t0 = _context2["catch"](0);
5827
+ return _context2.abrupt("return", false);
5828
+
5829
+ case 11:
5830
+ case "end":
5831
+ return _context2.stop();
5832
+ }
5833
+ }
5834
+ }, _callee2, null, [[0, 8]]);
5835
+ }));
5836
+ };
5837
+
5838
+ function onChangeTab(action, value) {
5839
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
5840
+ var taf;
5841
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
5842
+ while (1) {
5843
+ switch (_context3.prev = _context3.next) {
5486
5844
  case 0:
5487
5845
  if (!isFormDirty) {
5488
- _context2.next = 15;
5846
+ _context3.next = 15;
5489
5847
  break;
5490
5848
  }
5491
5849
 
5492
- _context2.prev = 1;
5493
- _context2.next = 4;
5850
+ _context3.prev = 1;
5851
+ _context3.next = 4;
5494
5852
  return onValidateForm();
5495
5853
 
5496
5854
  case 4:
5497
- taf = _context2.sent;
5498
- _context2.next = 7;
5855
+ taf = _context3.sent;
5856
+ _context3.next = 7;
5499
5857
  return postTaf({
5500
5858
  taf: taf,
5501
5859
  changeStatusTo: fromActionToStatus(tafActionToDraftAction(tafAction))
@@ -5503,19 +5861,19 @@ var TafLayout = function TafLayout(_ref) {
5503
5861
 
5504
5862
  case 7:
5505
5863
  action(value);
5506
- _context2.next = 13;
5864
+ _context3.next = 13;
5507
5865
  break;
5508
5866
 
5509
5867
  case 10:
5510
- _context2.prev = 10;
5511
- _context2.t0 = _context2["catch"](1);
5868
+ _context3.prev = 10;
5869
+ _context3.t0 = _context3["catch"](1);
5512
5870
  confirmDialog(CONFIRM_DIALOG_OPTIONS).then(function () {
5513
5871
  action(value);
5514
5872
  setError(null);
5515
5873
  });
5516
5874
 
5517
5875
  case 13:
5518
- _context2.next = 17;
5876
+ _context3.next = 17;
5519
5877
  break;
5520
5878
 
5521
5879
  case 15:
@@ -5524,10 +5882,10 @@ var TafLayout = function TafLayout(_ref) {
5524
5882
 
5525
5883
  case 17:
5526
5884
  case "end":
5527
- return _context2.stop();
5885
+ return _context3.stop();
5528
5886
  }
5529
5887
  }
5530
- }, _callee2, null, [[1, 10]]);
5888
+ }, _callee3, null, [[1, 10]]);
5531
5889
  }));
5532
5890
  }
5533
5891
 
@@ -5560,7 +5918,8 @@ var TafLayout = function TafLayout(_ref) {
5560
5918
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5561
5919
  }, [tafList, setLocations]);
5562
5920
  React__default.useEffect(function () {
5563
- var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
5921
+ setError(postError);
5922
+ var cancelErrorTimeout = postError && postError.type === 'CANCELLED' ? setTimeout(function () {
5564
5923
  setError(null);
5565
5924
  }, 10000) : null;
5566
5925
  return function () {
@@ -5568,7 +5927,10 @@ var TafLayout = function TafLayout(_ref) {
5568
5927
  clearTimeout(cancelErrorTimeout);
5569
5928
  }
5570
5929
  };
5571
- }, [error, setError]);
5930
+ }, [postError]);
5931
+ React__default.useEffect(function () {
5932
+ setError(patchError);
5933
+ }, [patchError]);
5572
5934
 
5573
5935
  if (!tafList) {
5574
5936
  return null;
@@ -5614,6 +5976,13 @@ var TafLayout = function TafLayout(_ref) {
5614
5976
  tafFromBackend: lastCurrentTaf,
5615
5977
  timeSlot: timeSlot,
5616
5978
  onChangeTimeSlot: onChangeTimeSlot
5979
+ })), /*#__PURE__*/React__default.createElement(Grid, {
5980
+ item: true,
5981
+ xs: 12,
5982
+ sm: 3
5983
+ }, lastUpdateTime && /*#__PURE__*/React__default.createElement(LastUpdateTime, {
5984
+ lastUpdateTime: lastUpdateTime,
5985
+ onUpdateTaf: onUpdateTaf
5617
5986
  }))), /*#__PURE__*/React__default.createElement(Grid, {
5618
5987
  container: true,
5619
5988
  flexGrow: 1,
@@ -5663,6 +6032,7 @@ var TafLayout = function TafLayout(_ref) {
5663
6032
  isFormDisabled: isFormDisabled,
5664
6033
  setIsFormDisabled: setIsFormDisabled,
5665
6034
  postTaf: postTaf,
6035
+ patchTaf: patchTaf,
5666
6036
  isLoading: isLoading,
5667
6037
  error: error
5668
6038
  });
@@ -5704,41 +6074,78 @@ var TafWrapper = function TafWrapper(_a) {
5704
6074
  }, children)));
5705
6075
  };
5706
6076
 
5707
- /* *
5708
- * Licensed under the Apache License, Version 2.0 (the "License");
5709
- * you may not use this file except in compliance with the License.
5710
- * You may obtain a copy of the License at
5711
- *
5712
- * http://www.apache.org/licenses/LICENSE-2.0
5713
- *
5714
- * Unless required by applicable law or agreed to in writing, software
5715
- * distributed under the License is distributed on an "AS IS" BASIS,
5716
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5717
- * See the License for the specific language governing permissions and
5718
- * limitations under the License.
5719
- *
5720
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5721
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
5722
- * */
6077
+ var getCurrentDate = function getCurrentDate() {
6078
+ return moment.utc().format('HH:mm');
6079
+ };
5723
6080
 
5724
6081
  var TafModule = function TafModule() {
5725
6082
  var _useApiContext = useApiContext(),
5726
6083
  api = _useApiContext.api;
5727
6084
 
5728
- var _useApi = useApi(api.getTafList),
5729
- getTafListError = _useApi.error,
5730
- isLoading = _useApi.isLoading,
5731
- tafList = _useApi.result,
5732
- fetchNewTafList = _useApi.fetchApiData;
6085
+ var _React$useState = React.useState([]),
6086
+ _React$useState2 = _slicedToArray(_React$useState, 2),
6087
+ tafList = _React$useState2[0],
6088
+ setTafList = _React$useState2[1];
5733
6089
 
5734
- usePoller([tafList, getTafListError], function () {
5735
- return fetchNewTafList({});
5736
- });
6090
+ var _React$useState3 = React.useState(true),
6091
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
6092
+ isLoading = _React$useState4[0],
6093
+ setIsLoading = _React$useState4[1];
6094
+
6095
+ var _React$useState5 = React.useState(null),
6096
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
6097
+ getTafListError = _React$useState6[0],
6098
+ setError = _React$useState6[1];
6099
+
6100
+ var _React$useState7 = React.useState(),
6101
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
6102
+ lastUpdateTime = _React$useState8[0],
6103
+ setLastUpdateTime = _React$useState8[1];
6104
+
6105
+ var fetchNewTafList = function fetchNewTafList() {
6106
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6107
+ var result;
6108
+ return regeneratorRuntime.wrap(function _callee$(_context) {
6109
+ while (1) {
6110
+ switch (_context.prev = _context.next) {
6111
+ case 0:
6112
+ setIsLoading(true);
6113
+ setError(null);
6114
+ _context.prev = 2;
6115
+ _context.next = 5;
6116
+ return api.getTafList();
6117
+
6118
+ case 5:
6119
+ result = _context.sent;
6120
+ setTafList(result.data);
6121
+ setIsLoading(false);
6122
+ setLastUpdateTime(getCurrentDate());
6123
+ _context.next = 15;
6124
+ break;
6125
+
6126
+ case 11:
6127
+ _context.prev = 11;
6128
+ _context.t0 = _context["catch"](2);
6129
+ setError(_context.t0);
6130
+ setIsLoading(false);
5737
6131
 
5738
- var onPostTaf = function onPostTaf() {
5739
- fetchNewTafList({});
6132
+ case 15:
6133
+ case "end":
6134
+ return _context.stop();
6135
+ }
6136
+ }
6137
+ }, _callee, null, [[2, 11]]);
6138
+ }));
6139
+ };
6140
+
6141
+ var onUpdateTaf = function onUpdateTaf() {
6142
+ fetchNewTafList();
5740
6143
  };
5741
6144
 
6145
+ React.useEffect(function () {
6146
+ fetchNewTafList(); // eslint-disable-next-line react-hooks/exhaustive-deps
6147
+ }, []);
6148
+ usePoller([tafList, getTafListError], fetchNewTafList);
5742
6149
  var hasTafListError = getTafListError !== null;
5743
6150
  return /*#__PURE__*/React.createElement(Box, {
5744
6151
  component: "div",
@@ -5763,7 +6170,8 @@ var TafModule = function TafModule() {
5763
6170
  }
5764
6171
  }), /*#__PURE__*/React.createElement(TafLayout, {
5765
6172
  tafList: tafList,
5766
- onPostTaf: onPostTaf
6173
+ onUpdateTaf: onUpdateTaf,
6174
+ lastUpdateTime: lastUpdateTime
5767
6175
  }));
5768
6176
  };
5769
6177
 
@@ -5785,10 +6193,32 @@ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, a
5785
6193
  return axiosInstance.post.apply(axiosInstance, ['/taf2tac'].concat([Object.assign({}, tafData)].concat(_toConsumableArray(signal ? [{
5786
6194
  signal: signal
5787
6195
  }] : []))));
6196
+ },
6197
+ patchTaf: function patchTaf(formData) {
6198
+ return axiosInstance.patch('/taf', Object.assign({}, formData));
5788
6199
  }
5789
6200
  };
5790
6201
  };
5791
6202
 
6203
+ /* *
6204
+ * Licensed under the Apache License, Version 2.0 (the "License");
6205
+ * you may not use this file except in compliance with the License.
6206
+ * You may obtain a copy of the License at
6207
+ *
6208
+ * http://www.apache.org/licenses/LICENSE-2.0
6209
+ *
6210
+ * Unless required by applicable law or agreed to in writing, software
6211
+ * distributed under the License is distributed on an "AS IS" BASIS,
6212
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6213
+ * See the License for the specific language governing permissions and
6214
+ * limitations under the License.
6215
+ *
6216
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
6217
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
6218
+ * */
6219
+
6220
+ var MOCK_USERNAME = 'user.name';
6221
+
5792
6222
  var currentDate = moment.utc().format('YYYY-MM-DD');
5793
6223
  var tomorrowDate = moment.utc().add(1, 'day').format('YYYY-MM-DD');
5794
6224
  var airportPeriod = 6;
@@ -5827,6 +6257,7 @@ var _validDateRange5 = validDateRange(moment.utc().add(-6, 'hours'), airportPeri
5827
6257
  var fakeTafList = [{
5828
6258
  creationDate: upcomingValidDateStart,
5829
6259
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6260
+ editor: MOCK_USERNAME,
5830
6261
  taf: {
5831
6262
  uuid: '5f9583fjdf0f337925',
5832
6263
  baseTime: upcomingValidDateStart,
@@ -5846,6 +6277,7 @@ var fakeTafList = [{
5846
6277
  }, {
5847
6278
  creationDate: upcomingValidDateStart,
5848
6279
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6280
+ editor: null,
5849
6281
  taf: {
5850
6282
  uuid: '5f9583fjd111137925',
5851
6283
  baseTime: upcomingValidDateStart,
@@ -5871,6 +6303,7 @@ var fakeTafList = [{
5871
6303
  }, {
5872
6304
  creationDate: upcomingValidDateStart,
5873
6305
  canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
6306
+ editor: null,
5874
6307
  taf: {
5875
6308
  uuid: '754905485',
5876
6309
  baseTime: upcomingValidDateStart,
@@ -5928,6 +6361,7 @@ var fakeTafList = [{
5928
6361
  }, {
5929
6362
  creationDate: upcomingValidDateStart,
5930
6363
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6364
+ editor: MOCK_USERNAME,
5931
6365
  taf: {
5932
6366
  uuid: '43545345345',
5933
6367
  issueDate: upcomingValidDateStart,
@@ -5998,6 +6432,7 @@ var fakeTafList = [{
5998
6432
  }, {
5999
6433
  creationDate: upcomingValidDateStart,
6000
6434
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6435
+ editor: null,
6001
6436
  taf: {
6002
6437
  uuid: '5f9583fjdf45ff4330f337925',
6003
6438
  issueDate: upcomingValidDateStart,
@@ -6053,6 +6488,7 @@ var fakeTafList = [{
6053
6488
  }, {
6054
6489
  creationDate: upcomingValidDateStart,
6055
6490
  canbe: ['AMENDED'],
6491
+ editor: null,
6056
6492
  taf: {
6057
6493
  uuid: '5464565464',
6058
6494
  previousId: '5445fghrfg3546456',
@@ -6094,6 +6530,7 @@ var fakeTafList = [{
6094
6530
  }, {
6095
6531
  creationDate: upcomingValidDateStart,
6096
6532
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6533
+ editor: 'max.jansen',
6097
6534
  taf: {
6098
6535
  uuid: 'gh56734fghfgh',
6099
6536
  previousId: '8574jnf93475',
@@ -6135,6 +6572,7 @@ var fakeTafList = [{
6135
6572
  }, {
6136
6573
  creationDate: currentValidDateStart,
6137
6574
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6575
+ editor: null,
6138
6576
  taf: {
6139
6577
  uuid: 'giskdj09845872039',
6140
6578
  issueDate: currentValidDateStart,
@@ -6174,6 +6612,7 @@ var fakeTafList = [{
6174
6612
  }, {
6175
6613
  creationDate: currentValidDateStart,
6176
6614
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6615
+ editor: null,
6177
6616
  taf: {
6178
6617
  uuid: 'ghskdj09845872039',
6179
6618
  baseTime: currentValidDateStart,
@@ -6193,6 +6632,7 @@ var fakeTafList = [{
6193
6632
  }, {
6194
6633
  creationDate: currentValidDateStart,
6195
6634
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6635
+ editor: null,
6196
6636
  taf: {
6197
6637
  uuid: 'ghskdj09845872040',
6198
6638
  issueDate: currentValidDateStart,
@@ -6213,6 +6653,7 @@ var fakeTafList = [{
6213
6653
  }, {
6214
6654
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6215
6655
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6656
+ editor: null,
6216
6657
  taf: {
6217
6658
  uuid: 'ghskdj09845872041',
6218
6659
  issueDate: currentValidDateStart,
@@ -6233,6 +6674,7 @@ var fakeTafList = [{
6233
6674
  }, {
6234
6675
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6235
6676
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6677
+ editor: null,
6236
6678
  taf: {
6237
6679
  uuid: 'ghskdj09845872042',
6238
6680
  issueDate: currentValidDateStart,
@@ -6253,6 +6695,7 @@ var fakeTafList = [{
6253
6695
  }, {
6254
6696
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6255
6697
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6698
+ editor: null,
6256
6699
  taf: {
6257
6700
  uuid: 'ghskdj09845872043',
6258
6701
  issueDate: currentValidDateStart,
@@ -6273,6 +6716,7 @@ var fakeTafList = [{
6273
6716
  }, {
6274
6717
  creationDate: expiredValidDateStart,
6275
6718
  canbe: [],
6719
+ editor: null,
6276
6720
  taf: {
6277
6721
  uuid: 'sdkjhsdf90845890',
6278
6722
  issueDate: expiredValidDateStart,
@@ -6337,6 +6781,7 @@ var fakeTafList = [{
6337
6781
  var fakeNewTaf = {
6338
6782
  creationDate: "".concat(currentDate, "T12:00:00Z"),
6339
6783
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6784
+ editor: null,
6340
6785
  taf: {
6341
6786
  type: 'NORMAL',
6342
6787
  messageType: 'ORG',
@@ -6357,6 +6802,7 @@ var fakeNewTaf = {
6357
6802
  ({
6358
6803
  creationDate: "2022-01-06T12:00:00Z",
6359
6804
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6805
+ editor: MOCK_USERNAME,
6360
6806
  taf: Object.assign(Object.assign({}, fakeNewTaf.taf), {
6361
6807
  baseTime: "2022-01-06T12:00:00Z",
6362
6808
  validDateStart: "2022-01-06T12:00:00Z",
@@ -6372,6 +6818,7 @@ var fakeNewTaf = {
6372
6818
  var fakePublishedTaf = {
6373
6819
  creationDate: "".concat(currentDate, "T12:00:00Z"),
6374
6820
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6821
+ editor: null,
6375
6822
  taf: {
6376
6823
  uuid: 'slsdkjg-023895',
6377
6824
  issueDate: "".concat(currentDate, "T12:00:00Z"),
@@ -6447,7 +6894,9 @@ var fakePublishedTaf = {
6447
6894
  ({
6448
6895
  creationDate: "2022-01-06T12:00:00Z",
6449
6896
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6897
+ editor: MOCK_USERNAME,
6450
6898
  taf: Object.assign(Object.assign({}, fakePublishedTaf.taf), {
6899
+ uuid: 'sowi3u4o-lsdjflsk',
6451
6900
  location: 'EHGG',
6452
6901
  baseTime: "2022-01-06T12:00:00Z",
6453
6902
  issueDate: "2022-01-06T12:00:00Z",
@@ -6512,6 +6961,7 @@ var fakePublishedTaf = {
6512
6961
  var fakeDraftTaf = {
6513
6962
  creationDate: "".concat(currentDate, "T18:00:00Z"),
6514
6963
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6964
+ editor: null,
6515
6965
  taf: {
6516
6966
  uuid: '5f9583fjdf0f337925',
6517
6967
  baseTime: "".concat(currentDate, "T18:00:00Z"),
@@ -6550,6 +7000,7 @@ var fakeDraftTaf = {
6550
7000
  ({
6551
7001
  creationDate: "2022-01-06T18:00:00Z",
6552
7002
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7003
+ editor: MOCK_USERNAME,
6553
7004
  taf: Object.assign(Object.assign({}, fakeDraftTaf.taf), {
6554
7005
  baseTime: "2022-01-06T18:00:00Z",
6555
7006
  validDateStart: "2022-01-06T18:00:00Z",
@@ -6565,6 +7016,7 @@ var fakeDraftTaf = {
6565
7016
  var fakeDraftAmendmentTaf = {
6566
7017
  creationDate: "".concat(currentDate, "T14:00:00Z"),
6567
7018
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7019
+ editor: null,
6568
7020
  taf: {
6569
7021
  uuid: '954905487',
6570
7022
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6625,6 +7077,7 @@ var fakeDraftAmendmentTaf = {
6625
7077
  ({
6626
7078
  creationDate: "2022-01-06T14:00:00Z",
6627
7079
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7080
+ editor: null,
6628
7081
  taf: Object.assign(Object.assign({}, fakeDraftAmendmentTaf.taf), {
6629
7082
  location: 'EHRD',
6630
7083
  issueDate: "2022-01-06T14:00:00Z",
@@ -6645,6 +7098,7 @@ var fakeDraftAmendmentTaf = {
6645
7098
  var fakeAmendmentTaf = {
6646
7099
  creationDate: "".concat(currentDate, "T14:00:00Z"),
6647
7100
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7101
+ editor: null,
6648
7102
  taf: {
6649
7103
  uuid: '754905486',
6650
7104
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6688,6 +7142,7 @@ var fakeAmendmentTaf = {
6688
7142
  ({
6689
7143
  creationDate: "2022-01-06T14:00:00Z",
6690
7144
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7145
+ editor: MOCK_USERNAME,
6691
7146
  taf: Object.assign(Object.assign({}, fakeAmendmentTaf.taf), {
6692
7147
  uuid: '7549058980',
6693
7148
  issueDate: "2022-01-06T14:00:00Z",
@@ -6722,6 +7177,14 @@ var fakePromise = function fakePromise(withRandomError) {
6722
7177
  });
6723
7178
  };
6724
7179
 
7180
+ var fakeUpdatedTafList = _toConsumableArray(fakeTafList);
7181
+
7182
+ var setFakeUpdatedList = function setFakeUpdatedList(newList) {
7183
+ fakeUpdatedTafList = newList;
7184
+ };
7185
+ var getFakeUpdatedList = function getFakeUpdatedList() {
7186
+ return fakeUpdatedTafList;
7187
+ };
6725
7188
  var fakeAxiosInstance = {
6726
7189
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6727
7190
  get: function get(_url, _params) {
@@ -6730,6 +7193,10 @@ var fakeAxiosInstance = {
6730
7193
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6731
7194
  post: function post(_url, _params, _signal) {
6732
7195
  return fakePromise(false, _signal);
7196
+ },
7197
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
7198
+ patch: function patch(_url, _params, _signal) {
7199
+ return fakePromise(false, _signal);
6733
7200
  }
6734
7201
  };
6735
7202
  var createApi = function createApi() {
@@ -6739,7 +7206,7 @@ var createApi = function createApi() {
6739
7206
  console.log('Retrieving new TAF list');
6740
7207
  return fakeAxiosInstance.get('/taflist').then(function () {
6741
7208
  return {
6742
- data: _toConsumableArray(fakeTafList)
7209
+ data: getFakeUpdatedList()
6743
7210
  };
6744
7211
  });
6745
7212
  },
@@ -6758,6 +7225,21 @@ var createApi = function createApi() {
6758
7225
  data: fakeTafTac
6759
7226
  };
6760
7227
  });
7228
+ },
7229
+ patchTaf: function patchTaf(_patchTaf) {
7230
+ var updatedList = getFakeUpdatedList().map(function (tafFromBackend) {
7231
+ if (tafFromBackend.taf.uuid === _patchTaf.taf.uuid) {
7232
+ return Object.assign(Object.assign({}, tafFromBackend), {
7233
+ editor: _patchTaf.editor
7234
+ });
7235
+ }
7236
+
7237
+ return tafFromBackend;
7238
+ });
7239
+ setFakeUpdatedList(updatedList); // eslint-disable-next-line no-console
7240
+
7241
+ console.log("The new editor of the taf will be ".concat(_patchTaf.editor || 'empty'));
7242
+ return fakeAxiosInstance.patch('/taf', _patchTaf);
6761
7243
  }
6762
7244
  };
6763
7245
  };