@opengeoweb/taf 2.12.0 → 2.15.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, 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,8 +4013,18 @@ 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;
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;
3946
4028
  var isDefaultDisabled = getIsFormDefaultDisabled(tafFromBackend.taf.status);
3947
4029
  var confirmDialog = useConfirmationDialog();
3948
4030
 
@@ -4047,6 +4129,93 @@ var TafForm = function TafForm(_ref) {
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(tafFromBackend.taf, 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,7 +4398,7 @@ var TafForm = function TafForm(_ref) {
4215
4398
  setShouldValidate = _React$useState4[1];
4216
4399
 
4217
4400
  React__default.useEffect(function () {
4218
- setIsDisabled(isDefaultDisabled);
4401
+ setIsDisabled(!isEditor || isDefaultDisabled);
4219
4402
  var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
4220
4403
 
4221
4404
  reset(defaultValues); // set validate flag to validate after the values have been set
@@ -4250,9 +4433,13 @@ var TafForm = function TafForm(_ref) {
4250
4433
 
4251
4434
  reset(newValues); // eslint-disable-next-line react-hooks/exhaustive-deps
4252
4435
  }, [tafFromBackend]);
4436
+ React__default.useEffect(function () {
4437
+ // update disabled state when editor changed
4438
+ setIsDisabled(!isEditor || isDefaultDisabled); // eslint-disable-next-line react-hooks/exhaustive-deps
4439
+ }, [editor]);
4253
4440
  React__default.useEffect(function () {
4254
4441
  if (shouldValidate && !isDisabled) {
4255
- // trigger validation on all changegroup validity times after initial load since they could be outside the new validity period
4442
+ // trigger validation on all changegroup validity times after form is enabled since they could be outside the new validity period
4256
4443
  var _tafFromBackend$taf$c = tafFromBackend.taf.changeGroups,
4257
4444
  changeGroups = _tafFromBackend$taf$c === void 0 ? [] : _tafFromBackend$taf$c;
4258
4445
  var validFields = changeGroups.map(function (_field, index) {
@@ -4261,8 +4448,33 @@ var TafForm = function TafForm(_ref) {
4261
4448
  trigger(validFields);
4262
4449
  } // eslint-disable-next-line react-hooks/exhaustive-deps
4263
4450
 
4264
- }, [shouldValidate]);
4265
- return /*#__PURE__*/React__default.createElement("form", {
4451
+ }, [shouldValidate, isDisabled]);
4452
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
4453
+ sx: {
4454
+ display: 'flex',
4455
+ flexDirection: 'row',
4456
+ alignItems: 'center',
4457
+ position: 'absolute',
4458
+ top: {
4459
+ xs: '20px',
4460
+ sm: '0px'
4461
+ },
4462
+ right: {
4463
+ xs: 'calc(50% - 70px)',
4464
+ sm: '8px'
4465
+ }
4466
+ }
4467
+ }, /*#__PURE__*/React__default.createElement(SwitchButton, {
4468
+ checked: isEditor,
4469
+ onChange: onSwitchMode
4470
+ }), /*#__PURE__*/React__default.createElement(Box, {
4471
+ sx: {
4472
+ width: '16px',
4473
+ marginLeft: 1
4474
+ }
4475
+ }, editor && /*#__PURE__*/React__default.createElement(TafAvatar, {
4476
+ editor: editor
4477
+ }))), /*#__PURE__*/React__default.createElement("form", {
4266
4478
  "data-testid": "taf-form",
4267
4479
  onSubmit: handleSubmit(onSubmit),
4268
4480
  onBlur: onFormBlur
@@ -4328,7 +4540,7 @@ var TafForm = function TafForm(_ref) {
4328
4540
  index: index
4329
4541
  })
4330
4542
  });
4331
- })), !isDisabled && /*#__PURE__*/React__default.createElement(Grid, {
4543
+ })), !isDisabled && isEditor && /*#__PURE__*/React__default.createElement(Grid, {
4332
4544
  container: true,
4333
4545
  justifyContent: "space-between",
4334
4546
  alignItems: "center",
@@ -4342,7 +4554,7 @@ var TafForm = function TafForm(_ref) {
4342
4554
  errors: errors,
4343
4555
  isIssuesPaneOpen: isIssuesPaneOpen,
4344
4556
  setIsIssuesPaneOpen: setIsIssuesPaneOpen
4345
- }))), /*#__PURE__*/React__default.createElement(TafFormButtons, {
4557
+ }))), isEditor && /*#__PURE__*/React__default.createElement(TafFormButtons, {
4346
4558
  isFormDisabled: isDisabled,
4347
4559
  tafAction: tafAction,
4348
4560
  canBe: tafFromBackend.canbe,
@@ -4353,8 +4565,12 @@ var TafForm = function TafForm(_ref) {
4353
4565
  name: field,
4354
4566
  key: field
4355
4567
  });
4356
- }), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null));
4357
- };
4568
+ }), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null)));
4569
+ }, function (prevProps, nextProps) {
4570
+ // prevent re-render
4571
+ return !nextProps.isDisabled && prevProps.tafFromBackend !== nextProps.tafFromBackend && // if editor changed it should rerender
4572
+ prevProps.tafFromBackend.editor === nextProps.tafFromBackend.editor;
4573
+ });
4358
4574
 
4359
4575
  /* *
4360
4576
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4591,7 +4807,6 @@ var StatusIcon = function StatusIcon(_ref2) {
4591
4807
  title: "Expired"
4592
4808
  }, /*#__PURE__*/React.createElement(Clock, {
4593
4809
  "data-testid": "status-expired",
4594
- fontSize: "small",
4595
4810
  sx: {
4596
4811
  transform: 'scaleX(-1)',
4597
4812
  color: 'geowebColors.buttons.tertiary.disabled.color'
@@ -4604,7 +4819,6 @@ var StatusIcon = function StatusIcon(_ref2) {
4604
4819
  title: "Cancelled"
4605
4820
  }, /*#__PURE__*/React.createElement(Cancel, {
4606
4821
  "data-testid": "status-cancelled",
4607
- fontSize: "small",
4608
4822
  sx: {
4609
4823
  color: 'geowebColors.captions.captionError.rgba'
4610
4824
  }
@@ -4616,7 +4830,6 @@ var StatusIcon = function StatusIcon(_ref2) {
4616
4830
  title: "Draft"
4617
4831
  }, /*#__PURE__*/React.createElement(Edit, {
4618
4832
  "data-testid": "status-draft",
4619
- fontSize: "small",
4620
4833
  sx: {
4621
4834
  color: 'geowebColors.buttons.tertiary.default.color'
4622
4835
  }
@@ -4627,7 +4840,6 @@ var StatusIcon = function StatusIcon(_ref2) {
4627
4840
  title: "Active"
4628
4841
  }, /*#__PURE__*/React.createElement(Success, {
4629
4842
  "data-testid": "status-active",
4630
- fontSize: "small",
4631
4843
  sx: {
4632
4844
  color: 'geowebColors.functional.success'
4633
4845
  }
@@ -4635,7 +4847,6 @@ var StatusIcon = function StatusIcon(_ref2) {
4635
4847
  title: "Upcoming"
4636
4848
  }, /*#__PURE__*/React.createElement(Clock, {
4637
4849
  "data-testid": "status-upcoming",
4638
- fontSize: "small",
4639
4850
  sx: {
4640
4851
  color: 'geowebColors.functional.success'
4641
4852
  }
@@ -4948,7 +5159,7 @@ var TacOverviewMobile = function TacOverviewMobile(_ref) {
4948
5159
  },
4949
5160
  position: 'absolute',
4950
5161
  right: '8px',
4951
- top: '30px'
5162
+ top: '48px'
4952
5163
  }
4953
5164
  }, /*#__PURE__*/React.createElement(ListItem, null)), /*#__PURE__*/React.createElement(Dialog, {
4954
5165
  open: isOpen,
@@ -5078,7 +5289,8 @@ var LocationTabs = function LocationTabs(_ref) {
5078
5289
  paddingTop: '32px'
5079
5290
  }
5080
5291
  }, tafList.map(function (_ref2, index) {
5081
- var taf = _ref2.taf;
5292
+ var taf = _ref2.taf,
5293
+ editor = _ref2.editor;
5082
5294
  return /*#__PURE__*/React.createElement(MenuItem, {
5083
5295
  key: taf.uuid,
5084
5296
  selected: index === activeIndex,
@@ -5103,8 +5315,18 @@ var LocationTabs = function LocationTabs(_ref) {
5103
5315
  onClick: function onClick() {
5104
5316
  return onChangeTab(index);
5105
5317
  }
5106
- }, /*#__PURE__*/React.createElement(Box$1, {
5318
+ }, editor && /*#__PURE__*/React.createElement(Box$1, {
5319
+ sx: {
5320
+ position: 'absolute',
5321
+ top: '4px',
5322
+ left: '8px'
5323
+ }
5324
+ }, /*#__PURE__*/React.createElement(TafAvatar, {
5325
+ editor: editor,
5326
+ tooltipPlacement: "right"
5327
+ })), /*#__PURE__*/React.createElement(Box$1, {
5107
5328
  component: "span",
5329
+ "data-testid": "taf-location",
5108
5330
  sx: {
5109
5331
  fontSize: '12px',
5110
5332
  fontWeight: '500',
@@ -5114,9 +5336,9 @@ var LocationTabs = function LocationTabs(_ref) {
5114
5336
  component: "span",
5115
5337
  sx: {
5116
5338
  position: 'absolute',
5117
- bottom: '1px',
5118
- width: '20px',
5119
- height: '20px'
5339
+ bottom: '-1px',
5340
+ width: '24px',
5341
+ height: '24px'
5120
5342
  }
5121
5343
  }, /*#__PURE__*/React.createElement(StatusIcon, {
5122
5344
  timeSlot: timeSlot,
@@ -5180,13 +5402,15 @@ var fromActionToStatus = function fromActionToStatus(tafAction) {
5180
5402
  };
5181
5403
 
5182
5404
  var parseErrorMessage = function parseErrorMessage(error, params) {
5405
+ var message = getErrorMessage$1(error);
5183
5406
  return params.changeStatusTo === 'CANCELLED' ? {
5184
5407
  type: 'CANCELLED',
5185
- title: 'Cancelling this TAF failed, please try again'
5408
+ title: 'Cancelling this TAF failed, please try again',
5409
+ message: message
5186
5410
  } : {
5187
5411
  type: 'SERVER',
5188
5412
  title: 'An error has occurred while saving, please try again',
5189
- message: isAxiosError(error) ? getAxiosErrorMessage(error) : error.message
5413
+ message: message
5190
5414
  };
5191
5415
  };
5192
5416
 
@@ -5277,6 +5501,10 @@ var TafPanel = function TafPanel(_ref) {
5277
5501
  postTaf = _ref$postTaf === void 0 ? function () {
5278
5502
  return null;
5279
5503
  } : _ref$postTaf,
5504
+ _ref$patchTaf = _ref.patchTaf,
5505
+ patchTaf = _ref$patchTaf === void 0 ? function () {
5506
+ return null;
5507
+ } : _ref$patchTaf,
5280
5508
  _ref$isIssuesPaneOpen = _ref.isIssuesPaneOpen,
5281
5509
  isIssuesPaneOpen = _ref$isIssuesPaneOpen === void 0 ? false : _ref$isIssuesPaneOpen,
5282
5510
  _ref$setIsIssuesPaneO = _ref.setIsIssuesPaneOpen,
@@ -5363,7 +5591,8 @@ var TafPanel = function TafPanel(_ref) {
5363
5591
  isIssuesPaneOpen: isIssuesPaneOpen,
5364
5592
  setIsIssuesPaneOpen: setIsIssuesPaneOpen,
5365
5593
  isDisabled: isFormDisabled,
5366
- setIsDisabled: setIsFormDisabled
5594
+ setIsDisabled: setIsFormDisabled,
5595
+ onSwitchEditor: patchTaf
5367
5596
  })));
5368
5597
  };
5369
5598
 
@@ -5394,6 +5623,57 @@ var IssuesPaneWrapper = function IssuesPaneWrapper(props) {
5394
5623
  }, props));
5395
5624
  };
5396
5625
 
5626
+ /* *
5627
+ * Licensed under the Apache License, Version 2.0 (the "License");
5628
+ * you may not use this file except in compliance with the License.
5629
+ * You may obtain a copy of the License at
5630
+ *
5631
+ * http://www.apache.org/licenses/LICENSE-2.0
5632
+ *
5633
+ * Unless required by applicable law or agreed to in writing, software
5634
+ * distributed under the License is distributed on an "AS IS" BASIS,
5635
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5636
+ * See the License for the specific language governing permissions and
5637
+ * limitations under the License.
5638
+ *
5639
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5640
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
5641
+ * */
5642
+ var getLastUpdateTitle = function getLastUpdateTitle(time) {
5643
+ return "Last updated ".concat(time);
5644
+ };
5645
+
5646
+ var LastUpdateTime = function LastUpdateTime(_ref) {
5647
+ var _ref$onUpdateTaf = _ref.onUpdateTaf,
5648
+ onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
5649
+ lastUpdateTime = _ref.lastUpdateTime;
5650
+ return /*#__PURE__*/React__default.createElement(Box, {
5651
+ sx: {
5652
+ display: 'flex',
5653
+ alignItems: 'center',
5654
+ height: '100%',
5655
+ justifyContent: 'flex-end'
5656
+ }
5657
+ }, /*#__PURE__*/React__default.createElement(Typography, {
5658
+ sx: {
5659
+ color: 'geowebColors.captions.captionStatus.rgba',
5660
+ fontSize: '10px',
5661
+ lineHeight: '1.6',
5662
+ letterSpacing: '0.33px'
5663
+ },
5664
+ "data-testid": "lastupdated-time"
5665
+ }, getLastUpdateTitle(lastUpdateTime)), /*#__PURE__*/React__default.createElement(Tooltip, {
5666
+ title: "Click to refresh"
5667
+ }, /*#__PURE__*/React__default.createElement(ToolButton, {
5668
+ "data-testid": "updateTafBtn",
5669
+ onClick: onUpdateTaf,
5670
+ sx: {
5671
+ marginRight: 1,
5672
+ marginLeft: 1
5673
+ }
5674
+ }, /*#__PURE__*/React__default.createElement(Cached, null))));
5675
+ };
5676
+
5397
5677
  var CONFIRM_DIALOG_OPTIONS = {
5398
5678
  title: 'Whoops',
5399
5679
  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.",
@@ -5403,8 +5683,9 @@ var CONFIRM_DIALOG_OPTIONS = {
5403
5683
  var TafLayout = function TafLayout(_ref) {
5404
5684
  var _ref$tafList = _ref.tafList,
5405
5685
  tafList = _ref$tafList === void 0 ? [] : _ref$tafList,
5406
- _ref$onPostTaf = _ref.onPostTaf,
5407
- onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
5686
+ _ref$onUpdateTaf = _ref.onUpdateTaf,
5687
+ onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
5688
+ lastUpdateTime = _ref.lastUpdateTime;
5408
5689
 
5409
5690
  var _useApiContext = useApiContext(),
5410
5691
  api = _useApiContext.api;
@@ -5420,8 +5701,11 @@ var TafLayout = function TafLayout(_ref) {
5420
5701
  var _usePostTafRequest = usePostTafRequest(api.postTaf),
5421
5702
  isLoading = _usePostTafRequest.isLoading,
5422
5703
  postTafRequest = _usePostTafRequest.doRequest,
5423
- error = _usePostTafRequest.error,
5424
- setError = _usePostTafRequest.setError;
5704
+ postError = _usePostTafRequest.error;
5705
+
5706
+ var _usePostTafRequest2 = usePostTafRequest(api.patchTaf),
5707
+ patchTafRequest = _usePostTafRequest2.doRequest,
5708
+ patchError = _usePostTafRequest2.error;
5425
5709
 
5426
5710
  var _useTafModuleContext = useTafModuleContext(),
5427
5711
  onValidateForm = _useTafModuleContext.onValidateForm,
@@ -5460,6 +5744,11 @@ var TafLayout = function TafLayout(_ref) {
5460
5744
  isFormDisabled = _React$useState10[0],
5461
5745
  setIsFormDisabled = _React$useState10[1];
5462
5746
 
5747
+ var _React$useState11 = React__default.useState(),
5748
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
5749
+ error = _React$useState12[0],
5750
+ setError = _React$useState12[1];
5751
+
5463
5752
  var postTaf = function postTaf(data) {
5464
5753
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
5465
5754
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -5471,7 +5760,7 @@ var TafLayout = function TafLayout(_ref) {
5471
5760
 
5472
5761
  case 2:
5473
5762
  // callback
5474
- onPostTaf();
5763
+ onUpdateTaf();
5475
5764
 
5476
5765
  case 3:
5477
5766
  case "end":
@@ -5482,25 +5771,54 @@ var TafLayout = function TafLayout(_ref) {
5482
5771
  }));
5483
5772
  };
5484
5773
 
5485
- function onChangeTab(action, value) {
5486
- return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5487
- var taf;
5774
+ var patchTaf = function patchTaf(data) {
5775
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5488
5776
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
5489
5777
  while (1) {
5490
5778
  switch (_context2.prev = _context2.next) {
5779
+ case 0:
5780
+ _context2.prev = 0;
5781
+ _context2.next = 3;
5782
+ return patchTafRequest(data);
5783
+
5784
+ case 3:
5785
+ // callback
5786
+ onUpdateTaf();
5787
+ return _context2.abrupt("return", true);
5788
+
5789
+ case 7:
5790
+ _context2.prev = 7;
5791
+ _context2.t0 = _context2["catch"](0);
5792
+ return _context2.abrupt("return", false);
5793
+
5794
+ case 10:
5795
+ case "end":
5796
+ return _context2.stop();
5797
+ }
5798
+ }
5799
+ }, _callee2, null, [[0, 7]]);
5800
+ }));
5801
+ };
5802
+
5803
+ function onChangeTab(action, value) {
5804
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
5805
+ var taf;
5806
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
5807
+ while (1) {
5808
+ switch (_context3.prev = _context3.next) {
5491
5809
  case 0:
5492
5810
  if (!isFormDirty) {
5493
- _context2.next = 15;
5811
+ _context3.next = 15;
5494
5812
  break;
5495
5813
  }
5496
5814
 
5497
- _context2.prev = 1;
5498
- _context2.next = 4;
5815
+ _context3.prev = 1;
5816
+ _context3.next = 4;
5499
5817
  return onValidateForm();
5500
5818
 
5501
5819
  case 4:
5502
- taf = _context2.sent;
5503
- _context2.next = 7;
5820
+ taf = _context3.sent;
5821
+ _context3.next = 7;
5504
5822
  return postTaf({
5505
5823
  taf: taf,
5506
5824
  changeStatusTo: fromActionToStatus(tafActionToDraftAction(tafAction))
@@ -5508,19 +5826,19 @@ var TafLayout = function TafLayout(_ref) {
5508
5826
 
5509
5827
  case 7:
5510
5828
  action(value);
5511
- _context2.next = 13;
5829
+ _context3.next = 13;
5512
5830
  break;
5513
5831
 
5514
5832
  case 10:
5515
- _context2.prev = 10;
5516
- _context2.t0 = _context2["catch"](1);
5833
+ _context3.prev = 10;
5834
+ _context3.t0 = _context3["catch"](1);
5517
5835
  confirmDialog(CONFIRM_DIALOG_OPTIONS).then(function () {
5518
5836
  action(value);
5519
5837
  setError(null);
5520
5838
  });
5521
5839
 
5522
5840
  case 13:
5523
- _context2.next = 17;
5841
+ _context3.next = 17;
5524
5842
  break;
5525
5843
 
5526
5844
  case 15:
@@ -5529,10 +5847,10 @@ var TafLayout = function TafLayout(_ref) {
5529
5847
 
5530
5848
  case 17:
5531
5849
  case "end":
5532
- return _context2.stop();
5850
+ return _context3.stop();
5533
5851
  }
5534
5852
  }
5535
- }, _callee2, null, [[1, 10]]);
5853
+ }, _callee3, null, [[1, 10]]);
5536
5854
  }));
5537
5855
  }
5538
5856
 
@@ -5565,7 +5883,8 @@ var TafLayout = function TafLayout(_ref) {
5565
5883
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5566
5884
  }, [tafList, setLocations]);
5567
5885
  React__default.useEffect(function () {
5568
- var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
5886
+ setError(postError);
5887
+ var cancelErrorTimeout = postError && postError.type === 'CANCELLED' ? setTimeout(function () {
5569
5888
  setError(null);
5570
5889
  }, 10000) : null;
5571
5890
  return function () {
@@ -5573,7 +5892,10 @@ var TafLayout = function TafLayout(_ref) {
5573
5892
  clearTimeout(cancelErrorTimeout);
5574
5893
  }
5575
5894
  };
5576
- }, [error, setError]);
5895
+ }, [postError]);
5896
+ React__default.useEffect(function () {
5897
+ setError(patchError);
5898
+ }, [patchError]);
5577
5899
 
5578
5900
  if (!tafList) {
5579
5901
  return null;
@@ -5619,6 +5941,13 @@ var TafLayout = function TafLayout(_ref) {
5619
5941
  tafFromBackend: lastCurrentTaf,
5620
5942
  timeSlot: timeSlot,
5621
5943
  onChangeTimeSlot: onChangeTimeSlot
5944
+ })), /*#__PURE__*/React__default.createElement(Grid, {
5945
+ item: true,
5946
+ xs: 12,
5947
+ sm: 3
5948
+ }, lastUpdateTime && /*#__PURE__*/React__default.createElement(LastUpdateTime, {
5949
+ lastUpdateTime: lastUpdateTime,
5950
+ onUpdateTaf: onUpdateTaf
5622
5951
  }))), /*#__PURE__*/React__default.createElement(Grid, {
5623
5952
  container: true,
5624
5953
  flexGrow: 1,
@@ -5668,6 +5997,7 @@ var TafLayout = function TafLayout(_ref) {
5668
5997
  isFormDisabled: isFormDisabled,
5669
5998
  setIsFormDisabled: setIsFormDisabled,
5670
5999
  postTaf: postTaf,
6000
+ patchTaf: patchTaf,
5671
6001
  isLoading: isLoading,
5672
6002
  error: error
5673
6003
  });
@@ -5709,41 +6039,78 @@ var TafWrapper = function TafWrapper(_a) {
5709
6039
  }, children)));
5710
6040
  };
5711
6041
 
5712
- /* *
5713
- * Licensed under the Apache License, Version 2.0 (the "License");
5714
- * you may not use this file except in compliance with the License.
5715
- * You may obtain a copy of the License at
5716
- *
5717
- * http://www.apache.org/licenses/LICENSE-2.0
5718
- *
5719
- * Unless required by applicable law or agreed to in writing, software
5720
- * distributed under the License is distributed on an "AS IS" BASIS,
5721
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5722
- * See the License for the specific language governing permissions and
5723
- * limitations under the License.
5724
- *
5725
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5726
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
5727
- * */
6042
+ var getCurrentDate = function getCurrentDate() {
6043
+ return moment.utc().format('HH:mm');
6044
+ };
5728
6045
 
5729
6046
  var TafModule = function TafModule() {
5730
6047
  var _useApiContext = useApiContext(),
5731
6048
  api = _useApiContext.api;
5732
6049
 
5733
- var _useApi = useApi(api.getTafList),
5734
- getTafListError = _useApi.error,
5735
- isLoading = _useApi.isLoading,
5736
- tafList = _useApi.result,
5737
- fetchNewTafList = _useApi.fetchApiData;
6050
+ var _React$useState = React.useState([]),
6051
+ _React$useState2 = _slicedToArray(_React$useState, 2),
6052
+ tafList = _React$useState2[0],
6053
+ setTafList = _React$useState2[1];
5738
6054
 
5739
- usePoller([tafList, getTafListError], function () {
5740
- return fetchNewTafList({});
5741
- });
6055
+ var _React$useState3 = React.useState(true),
6056
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
6057
+ isLoading = _React$useState4[0],
6058
+ setIsLoading = _React$useState4[1];
6059
+
6060
+ var _React$useState5 = React.useState(null),
6061
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
6062
+ getTafListError = _React$useState6[0],
6063
+ setError = _React$useState6[1];
6064
+
6065
+ var _React$useState7 = React.useState(),
6066
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
6067
+ lastUpdateTime = _React$useState8[0],
6068
+ setLastUpdateTime = _React$useState8[1];
6069
+
6070
+ var fetchNewTafList = function fetchNewTafList() {
6071
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6072
+ var result;
6073
+ return regeneratorRuntime.wrap(function _callee$(_context) {
6074
+ while (1) {
6075
+ switch (_context.prev = _context.next) {
6076
+ case 0:
6077
+ setIsLoading(true);
6078
+ setError(null);
6079
+ _context.prev = 2;
6080
+ _context.next = 5;
6081
+ return api.getTafList();
6082
+
6083
+ case 5:
6084
+ result = _context.sent;
6085
+ setTafList(result.data);
6086
+ setIsLoading(false);
6087
+ setLastUpdateTime(getCurrentDate());
6088
+ _context.next = 15;
6089
+ break;
6090
+
6091
+ case 11:
6092
+ _context.prev = 11;
6093
+ _context.t0 = _context["catch"](2);
6094
+ setError(_context.t0);
6095
+ setIsLoading(false);
6096
+
6097
+ case 15:
6098
+ case "end":
6099
+ return _context.stop();
6100
+ }
6101
+ }
6102
+ }, _callee, null, [[2, 11]]);
6103
+ }));
6104
+ };
5742
6105
 
5743
- var onPostTaf = function onPostTaf() {
5744
- fetchNewTafList({});
6106
+ var onUpdateTaf = function onUpdateTaf() {
6107
+ fetchNewTafList();
5745
6108
  };
5746
6109
 
6110
+ React.useEffect(function () {
6111
+ fetchNewTafList(); // eslint-disable-next-line react-hooks/exhaustive-deps
6112
+ }, []);
6113
+ usePoller([tafList, getTafListError], fetchNewTafList);
5747
6114
  var hasTafListError = getTafListError !== null;
5748
6115
  return /*#__PURE__*/React.createElement(Box, {
5749
6116
  component: "div",
@@ -5768,7 +6135,8 @@ var TafModule = function TafModule() {
5768
6135
  }
5769
6136
  }), /*#__PURE__*/React.createElement(TafLayout, {
5770
6137
  tafList: tafList,
5771
- onPostTaf: onPostTaf
6138
+ onUpdateTaf: onUpdateTaf,
6139
+ lastUpdateTime: lastUpdateTime
5772
6140
  }));
5773
6141
  };
5774
6142
 
@@ -5790,10 +6158,32 @@ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, a
5790
6158
  return axiosInstance.post.apply(axiosInstance, ['/taf2tac'].concat([Object.assign({}, tafData)].concat(_toConsumableArray(signal ? [{
5791
6159
  signal: signal
5792
6160
  }] : []))));
6161
+ },
6162
+ patchTaf: function patchTaf(formData) {
6163
+ return axiosInstance.patch('/taf', Object.assign({}, formData));
5793
6164
  }
5794
6165
  };
5795
6166
  };
5796
6167
 
6168
+ /* *
6169
+ * Licensed under the Apache License, Version 2.0 (the "License");
6170
+ * you may not use this file except in compliance with the License.
6171
+ * You may obtain a copy of the License at
6172
+ *
6173
+ * http://www.apache.org/licenses/LICENSE-2.0
6174
+ *
6175
+ * Unless required by applicable law or agreed to in writing, software
6176
+ * distributed under the License is distributed on an "AS IS" BASIS,
6177
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6178
+ * See the License for the specific language governing permissions and
6179
+ * limitations under the License.
6180
+ *
6181
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
6182
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
6183
+ * */
6184
+
6185
+ var MOCK_USERNAME = 'user.name';
6186
+
5797
6187
  var currentDate = moment.utc().format('YYYY-MM-DD');
5798
6188
  var tomorrowDate = moment.utc().add(1, 'day').format('YYYY-MM-DD');
5799
6189
  var airportPeriod = 6;
@@ -5832,6 +6222,7 @@ var _validDateRange5 = validDateRange(moment.utc().add(-6, 'hours'), airportPeri
5832
6222
  var fakeTafList = [{
5833
6223
  creationDate: upcomingValidDateStart,
5834
6224
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6225
+ editor: MOCK_USERNAME,
5835
6226
  taf: {
5836
6227
  uuid: '5f9583fjdf0f337925',
5837
6228
  baseTime: upcomingValidDateStart,
@@ -5851,6 +6242,7 @@ var fakeTafList = [{
5851
6242
  }, {
5852
6243
  creationDate: upcomingValidDateStart,
5853
6244
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6245
+ editor: null,
5854
6246
  taf: {
5855
6247
  uuid: '5f9583fjd111137925',
5856
6248
  baseTime: upcomingValidDateStart,
@@ -5876,6 +6268,7 @@ var fakeTafList = [{
5876
6268
  }, {
5877
6269
  creationDate: upcomingValidDateStart,
5878
6270
  canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
6271
+ editor: null,
5879
6272
  taf: {
5880
6273
  uuid: '754905485',
5881
6274
  baseTime: upcomingValidDateStart,
@@ -5933,6 +6326,7 @@ var fakeTafList = [{
5933
6326
  }, {
5934
6327
  creationDate: upcomingValidDateStart,
5935
6328
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6329
+ editor: MOCK_USERNAME,
5936
6330
  taf: {
5937
6331
  uuid: '43545345345',
5938
6332
  issueDate: upcomingValidDateStart,
@@ -6003,6 +6397,7 @@ var fakeTafList = [{
6003
6397
  }, {
6004
6398
  creationDate: upcomingValidDateStart,
6005
6399
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6400
+ editor: null,
6006
6401
  taf: {
6007
6402
  uuid: '5f9583fjdf45ff4330f337925',
6008
6403
  issueDate: upcomingValidDateStart,
@@ -6058,6 +6453,7 @@ var fakeTafList = [{
6058
6453
  }, {
6059
6454
  creationDate: upcomingValidDateStart,
6060
6455
  canbe: ['AMENDED'],
6456
+ editor: null,
6061
6457
  taf: {
6062
6458
  uuid: '5464565464',
6063
6459
  previousId: '5445fghrfg3546456',
@@ -6099,6 +6495,7 @@ var fakeTafList = [{
6099
6495
  }, {
6100
6496
  creationDate: upcomingValidDateStart,
6101
6497
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6498
+ editor: 'max.jansen',
6102
6499
  taf: {
6103
6500
  uuid: 'gh56734fghfgh',
6104
6501
  previousId: '8574jnf93475',
@@ -6140,6 +6537,7 @@ var fakeTafList = [{
6140
6537
  }, {
6141
6538
  creationDate: currentValidDateStart,
6142
6539
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6540
+ editor: null,
6143
6541
  taf: {
6144
6542
  uuid: 'giskdj09845872039',
6145
6543
  issueDate: currentValidDateStart,
@@ -6179,6 +6577,7 @@ var fakeTafList = [{
6179
6577
  }, {
6180
6578
  creationDate: currentValidDateStart,
6181
6579
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6580
+ editor: null,
6182
6581
  taf: {
6183
6582
  uuid: 'ghskdj09845872039',
6184
6583
  baseTime: currentValidDateStart,
@@ -6198,6 +6597,7 @@ var fakeTafList = [{
6198
6597
  }, {
6199
6598
  creationDate: currentValidDateStart,
6200
6599
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6600
+ editor: null,
6201
6601
  taf: {
6202
6602
  uuid: 'ghskdj09845872040',
6203
6603
  issueDate: currentValidDateStart,
@@ -6218,6 +6618,7 @@ var fakeTafList = [{
6218
6618
  }, {
6219
6619
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6220
6620
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6621
+ editor: null,
6221
6622
  taf: {
6222
6623
  uuid: 'ghskdj09845872041',
6223
6624
  issueDate: currentValidDateStart,
@@ -6238,6 +6639,7 @@ var fakeTafList = [{
6238
6639
  }, {
6239
6640
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6240
6641
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6642
+ editor: null,
6241
6643
  taf: {
6242
6644
  uuid: 'ghskdj09845872042',
6243
6645
  issueDate: currentValidDateStart,
@@ -6258,6 +6660,7 @@ var fakeTafList = [{
6258
6660
  }, {
6259
6661
  creationDate: "".concat(currentDate, "T06:00:00Z"),
6260
6662
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6663
+ editor: null,
6261
6664
  taf: {
6262
6665
  uuid: 'ghskdj09845872043',
6263
6666
  issueDate: currentValidDateStart,
@@ -6278,6 +6681,7 @@ var fakeTafList = [{
6278
6681
  }, {
6279
6682
  creationDate: expiredValidDateStart,
6280
6683
  canbe: [],
6684
+ editor: null,
6281
6685
  taf: {
6282
6686
  uuid: 'sdkjhsdf90845890',
6283
6687
  issueDate: expiredValidDateStart,
@@ -6342,6 +6746,7 @@ var fakeTafList = [{
6342
6746
  var fakeNewTaf = {
6343
6747
  creationDate: "".concat(currentDate, "T12:00:00Z"),
6344
6748
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6749
+ editor: null,
6345
6750
  taf: {
6346
6751
  type: 'NORMAL',
6347
6752
  messageType: 'ORG',
@@ -6362,6 +6767,7 @@ var fakeNewTaf = {
6362
6767
  ({
6363
6768
  creationDate: "2022-01-06T12:00:00Z",
6364
6769
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6770
+ editor: MOCK_USERNAME,
6365
6771
  taf: Object.assign(Object.assign({}, fakeNewTaf.taf), {
6366
6772
  baseTime: "2022-01-06T12:00:00Z",
6367
6773
  validDateStart: "2022-01-06T12:00:00Z",
@@ -6377,6 +6783,7 @@ var fakeNewTaf = {
6377
6783
  var fakePublishedTaf = {
6378
6784
  creationDate: "".concat(currentDate, "T12:00:00Z"),
6379
6785
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6786
+ editor: null,
6380
6787
  taf: {
6381
6788
  uuid: 'slsdkjg-023895',
6382
6789
  issueDate: "".concat(currentDate, "T12:00:00Z"),
@@ -6452,7 +6859,9 @@ var fakePublishedTaf = {
6452
6859
  ({
6453
6860
  creationDate: "2022-01-06T12:00:00Z",
6454
6861
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6862
+ editor: MOCK_USERNAME,
6455
6863
  taf: Object.assign(Object.assign({}, fakePublishedTaf.taf), {
6864
+ uuid: 'sowi3u4o-lsdjflsk',
6456
6865
  location: 'EHGG',
6457
6866
  baseTime: "2022-01-06T12:00:00Z",
6458
6867
  issueDate: "2022-01-06T12:00:00Z",
@@ -6517,6 +6926,7 @@ var fakePublishedTaf = {
6517
6926
  var fakeDraftTaf = {
6518
6927
  creationDate: "".concat(currentDate, "T18:00:00Z"),
6519
6928
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6929
+ editor: null,
6520
6930
  taf: {
6521
6931
  uuid: '5f9583fjdf0f337925',
6522
6932
  baseTime: "".concat(currentDate, "T18:00:00Z"),
@@ -6555,6 +6965,7 @@ var fakeDraftTaf = {
6555
6965
  ({
6556
6966
  creationDate: "2022-01-06T18:00:00Z",
6557
6967
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6968
+ editor: MOCK_USERNAME,
6558
6969
  taf: Object.assign(Object.assign({}, fakeDraftTaf.taf), {
6559
6970
  baseTime: "2022-01-06T18:00:00Z",
6560
6971
  validDateStart: "2022-01-06T18:00:00Z",
@@ -6570,6 +6981,7 @@ var fakeDraftTaf = {
6570
6981
  var fakeDraftAmendmentTaf = {
6571
6982
  creationDate: "".concat(currentDate, "T14:00:00Z"),
6572
6983
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6984
+ editor: null,
6573
6985
  taf: {
6574
6986
  uuid: '954905487',
6575
6987
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6630,6 +7042,7 @@ var fakeDraftAmendmentTaf = {
6630
7042
  ({
6631
7043
  creationDate: "2022-01-06T14:00:00Z",
6632
7044
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7045
+ editor: null,
6633
7046
  taf: Object.assign(Object.assign({}, fakeDraftAmendmentTaf.taf), {
6634
7047
  location: 'EHRD',
6635
7048
  issueDate: "2022-01-06T14:00:00Z",
@@ -6650,6 +7063,7 @@ var fakeDraftAmendmentTaf = {
6650
7063
  var fakeAmendmentTaf = {
6651
7064
  creationDate: "".concat(currentDate, "T14:00:00Z"),
6652
7065
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7066
+ editor: null,
6653
7067
  taf: {
6654
7068
  uuid: '754905486',
6655
7069
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6693,6 +7107,7 @@ var fakeAmendmentTaf = {
6693
7107
  ({
6694
7108
  creationDate: "2022-01-06T14:00:00Z",
6695
7109
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7110
+ editor: MOCK_USERNAME,
6696
7111
  taf: Object.assign(Object.assign({}, fakeAmendmentTaf.taf), {
6697
7112
  uuid: '7549058980',
6698
7113
  issueDate: "2022-01-06T14:00:00Z",
@@ -6727,6 +7142,14 @@ var fakePromise = function fakePromise(withRandomError) {
6727
7142
  });
6728
7143
  };
6729
7144
 
7145
+ var fakeUpdatedTafList = _toConsumableArray(fakeTafList);
7146
+
7147
+ var setFakeUpdatedList = function setFakeUpdatedList(newList) {
7148
+ fakeUpdatedTafList = newList;
7149
+ };
7150
+ var getFakeUpdatedList = function getFakeUpdatedList() {
7151
+ return fakeUpdatedTafList;
7152
+ };
6730
7153
  var fakeAxiosInstance = {
6731
7154
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6732
7155
  get: function get(_url, _params) {
@@ -6735,6 +7158,10 @@ var fakeAxiosInstance = {
6735
7158
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6736
7159
  post: function post(_url, _params, _signal) {
6737
7160
  return fakePromise(false, _signal);
7161
+ },
7162
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
7163
+ patch: function patch(_url, _params, _signal) {
7164
+ return fakePromise(false, _signal);
6738
7165
  }
6739
7166
  };
6740
7167
  var createApi = function createApi() {
@@ -6744,7 +7171,7 @@ var createApi = function createApi() {
6744
7171
  console.log('Retrieving new TAF list');
6745
7172
  return fakeAxiosInstance.get('/taflist').then(function () {
6746
7173
  return {
6747
- data: _toConsumableArray(fakeTafList)
7174
+ data: getFakeUpdatedList()
6748
7175
  };
6749
7176
  });
6750
7177
  },
@@ -6763,6 +7190,21 @@ var createApi = function createApi() {
6763
7190
  data: fakeTafTac
6764
7191
  };
6765
7192
  });
7193
+ },
7194
+ patchTaf: function patchTaf(_patchTaf) {
7195
+ var updatedList = getFakeUpdatedList().map(function (tafFromBackend) {
7196
+ if (tafFromBackend.taf.uuid === _patchTaf.taf.uuid) {
7197
+ return Object.assign(Object.assign({}, tafFromBackend), {
7198
+ editor: _patchTaf.editor
7199
+ });
7200
+ }
7201
+
7202
+ return tafFromBackend;
7203
+ });
7204
+ setFakeUpdatedList(updatedList); // eslint-disable-next-line no-console
7205
+
7206
+ console.log("The new editor of the taf will be ".concat(_patchTaf.editor || 'empty'));
7207
+ return fakeAxiosInstance.patch('/taf', _patchTaf);
6766
7208
  }
6767
7209
  };
6768
7210
  };