@opengeoweb/taf 2.3.0 → 2.4.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.
Files changed (82) hide show
  1. package/README.md +2 -2
  2. package/index.d.ts +1 -3
  3. package/index.esm.js +1470 -1287
  4. package/index.umd.js +1572 -1287
  5. package/lib/TafDemo.stories.d.ts +2 -2
  6. package/lib/components/IssuesPane/IssuesButton.d.ts +8 -2
  7. package/lib/components/IssuesPane/IssuesPane.d.ts +5 -0
  8. package/lib/components/IssuesPane/IssuesPane.stories.d.ts +12 -3
  9. package/lib/components/Spinner/Spinner.d.ts +2 -1
  10. package/lib/components/{TafLayout → StatusIcon}/StatusIcon.d.ts +0 -0
  11. package/lib/components/{TafLayout → StatusIcon}/StatusIcon.spec.d.ts +0 -0
  12. package/lib/components/{TafLayout/TabPanel → TabPanel}/TabPanel.d.ts +0 -0
  13. package/lib/components/{TafLayout/TabPanel → TabPanel}/TabPanel.spec.d.ts +0 -0
  14. package/lib/components/{TafLayout/TabPanel → TabPanel}/index.d.ts +0 -0
  15. package/lib/components/TafForm/TafForm.d.ts +1 -19
  16. package/lib/components/TafForm/TafFormButtons/TafFormButtons.d.ts +5 -9
  17. package/lib/components/TafForm/TafFormRow/{change.d.ts → validations/change.d.ts} +0 -0
  18. package/lib/components/TafForm/TafFormRow/{change.spec.d.ts → validations/change.spec.d.ts} +0 -0
  19. package/lib/components/TafForm/TafFormRow/{clouds.d.ts → validations/clouds.d.ts} +1 -1
  20. package/lib/components/TafForm/TafFormRow/{clouds.spec.d.ts → validations/clouds.spec.d.ts} +0 -0
  21. package/lib/components/TafForm/TafFormRow/{probability.d.ts → validations/probability.d.ts} +0 -0
  22. package/lib/components/TafForm/TafFormRow/{probability.spec.d.ts → validations/probability.spec.d.ts} +0 -0
  23. package/lib/components/TafForm/TafFormRow/{utils.d.ts → validations/utils.d.ts} +0 -0
  24. package/lib/components/TafForm/TafFormRow/{utils.spec.d.ts → validations/utils.spec.d.ts} +0 -0
  25. package/lib/components/TafForm/TafFormRow/{validField.d.ts → validations/validField.d.ts} +1 -1
  26. package/lib/components/TafForm/TafFormRow/{validField.spec.d.ts → validations/validField.spec.d.ts} +0 -0
  27. package/lib/components/TafForm/TafFormRow/{visibility.d.ts → validations/visibility.d.ts} +1 -1
  28. package/lib/components/TafForm/TafFormRow/{visibility.spec.d.ts → validations/visibility.spec.d.ts} +0 -0
  29. package/lib/components/TafForm/TafFormRow/{weather.d.ts → validations/weather.d.ts} +1 -1
  30. package/lib/components/TafForm/TafFormRow/{weather.spec.d.ts → validations/weather.spec.d.ts} +0 -0
  31. package/lib/components/TafForm/TafFormRow/{wind.d.ts → validations/wind.d.ts} +1 -1
  32. package/lib/components/TafForm/TafFormRow/{wind.spec.d.ts → validations/wind.spec.d.ts} +0 -0
  33. package/lib/components/TafForm/TafFormWrapper.d.ts +3 -6
  34. package/lib/components/TafForm/index.d.ts +0 -1
  35. package/lib/components/TafForm/utils.d.ts +21 -0
  36. package/lib/components/{TafLayout → TafHeader}/TafHeader.d.ts +0 -0
  37. package/lib/components/{TafLayout → TafHeader}/TafHeader.spec.d.ts +0 -0
  38. package/lib/components/TafLayout/TacOverview/TacContainer.d.ts +3 -4
  39. package/lib/components/TafLayout/TacOverview/TacOverview.d.ts +2 -0
  40. package/lib/components/TafLayout/TacOverview/TacOverview.stories.d.ts +2 -0
  41. package/lib/components/TafLayout/TacOverview/TacOverviewMobile.d.ts +11 -0
  42. package/lib/components/{ContentDialog/ContentDialog.spec.d.ts → TafLayout/TacOverview/TacOverviewMobile.spec.d.ts} +0 -0
  43. package/lib/components/TafLayout/TacOverview/TacOverviewMobile.stories.d.ts +23 -0
  44. package/lib/components/TafLayout/TacOverview/index.d.ts +1 -0
  45. package/lib/components/TafLayout/TafLayout.d.ts +1 -0
  46. package/lib/components/{TafForm/TafFormDialog/TafFormDialog.spec.d.ts → TafLayout/TafLayout.spec.d.ts} +0 -0
  47. package/lib/components/TafLayout/TafPanel/TafPanel.d.ts +10 -0
  48. package/lib/components/{TafList/TafList.spec.d.ts → TafLayout/TafPanel/TafPanel.spec.d.ts} +0 -0
  49. package/lib/components/TafLayout/TafPanel/index.d.ts +1 -0
  50. package/lib/components/TafModule/TafModule.d.ts +3 -0
  51. package/lib/components/{TafList/TafListAccordion.spec.d.ts → TafModule/TafModule.spec.d.ts} +0 -0
  52. package/lib/components/TafModule/TafModule.stories.d.ts +9 -0
  53. package/lib/components/TafModule/index.d.ts +1 -0
  54. package/lib/types.d.ts +2 -1
  55. package/lib/utils/__mocks__/api.d.ts +1 -0
  56. package/lib/utils/fakeApi.d.ts +1 -1
  57. package/lib/utils/mockdata/fakeTafList.d.ts +1 -0
  58. package/lib/utils/testUtils.d.ts +1 -10
  59. package/package.json +7 -6
  60. package/lib/components/ContentDialog/ContentDialog.d.ts +0 -14
  61. package/lib/components/ContentDialog/ContentDialog.stories.d.ts +0 -7
  62. package/lib/components/ContentDialog/index.d.ts +0 -1
  63. package/lib/components/IssuesPane/IssuesPane.styles.d.ts +0 -1
  64. package/lib/components/TafForm/TafFormDialog/TafFormDialog.d.ts +0 -12
  65. package/lib/components/TafForm/TafFormDialog/TafFormDialog.stories.d.ts +0 -9
  66. package/lib/components/TafList/TafList.d.ts +0 -11
  67. package/lib/components/TafList/TafList.stories.d.ts +0 -8
  68. package/lib/components/TafList/TafListAccordion.d.ts +0 -11
  69. package/lib/components/TafList/TafListButtons.d.ts +0 -10
  70. package/lib/components/TafList/TafListButtons.spec.d.ts +0 -1
  71. package/lib/components/TafList/TafListRow.d.ts +0 -12
  72. package/lib/components/TafList/TafListRow.spec.d.ts +0 -1
  73. package/lib/components/TafList/TafListSection.d.ts +0 -12
  74. package/lib/components/TafList/TafListSection.spec.d.ts +0 -1
  75. package/lib/components/TafList/TafListSection.stories.d.ts +0 -18
  76. package/lib/components/TafList/index.d.ts +0 -3
  77. package/lib/components/TafList/utils.d.ts +0 -4
  78. package/lib/components/TafList/utils.spec.d.ts +0 -1
  79. package/lib/components/TafWrapper/TafWrapper.d.ts +0 -13
  80. package/lib/components/TafWrapper/TafWrapper.spec.d.ts +0 -1
  81. package/lib/components/TafWrapper/index.d.ts +0 -1
  82. package/lib/utils/utils.d.ts +0 -3
package/index.esm.js CHANGED
@@ -1,15 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { TextField, SvgIcon, Grid, Box, Tooltip, Chip, Typography, Button, IconButton, Dialog, DialogTitle, DialogContent, Card, Accordion, AccordionSummary, AccordionDetails, Skeleton, Backdrop, CircularProgress } from '@mui/material';
4
- import makeStyles from '@mui/styles/makeStyles';
5
- import moment from 'moment';
6
- import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
7
- import { DragIndicator, Close, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@mui/icons-material';
8
- import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
9
3
  import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
4
+ import { TextField, SvgIcon, Grid, Box, Button, IconButton, Typography, Tooltip, Chip, useTheme, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
10
5
  import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
11
6
  import { ReactSortable, Sortable } from 'react-sortablejs';
7
+ import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
8
+ import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, AlertBanner, getAxiosErrorMessage, ConfirmationServiceProvider, usePoller } from '@opengeoweb/shared';
9
+ import moment from 'moment';
12
10
  import { isEqual } from 'lodash';
11
+ import makeStyles from '@mui/styles/makeStyles';
12
+ import { DragIndicator, Schedule, CheckCircle } from '@mui/icons-material';
13
+ import ReactDOM from 'react-dom';
14
+ import LinearProgress from '@mui/material/LinearProgress';
15
+ import DoDisturbIcon from '@mui/icons-material/DoDisturb';
16
+ import Box$1 from '@mui/material/Box';
13
17
 
14
18
  function _typeof(obj) {
15
19
  "@babel/helpers - typeof";
@@ -118,134 +122,6 @@ function _nonIterableRest() {
118
122
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
119
123
  }
120
124
 
121
- function _createForOfIteratorHelper(o, allowArrayLike) {
122
- var it;
123
-
124
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
125
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
126
- if (it) o = it;
127
- var i = 0;
128
-
129
- var F = function () {};
130
-
131
- return {
132
- s: F,
133
- n: function () {
134
- if (i >= o.length) return {
135
- done: true
136
- };
137
- return {
138
- done: false,
139
- value: o[i++]
140
- };
141
- },
142
- e: function (e) {
143
- throw e;
144
- },
145
- f: F
146
- };
147
- }
148
-
149
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
150
- }
151
-
152
- var normalCompletion = true,
153
- didErr = false,
154
- err;
155
- return {
156
- s: function () {
157
- it = o[Symbol.iterator]();
158
- },
159
- n: function () {
160
- var step = it.next();
161
- normalCompletion = step.done;
162
- return step;
163
- },
164
- e: function (e) {
165
- didErr = true;
166
- err = e;
167
- },
168
- f: function () {
169
- try {
170
- if (!normalCompletion && it.return != null) it.return();
171
- } finally {
172
- if (didErr) throw err;
173
- }
174
- }
175
- };
176
- }
177
-
178
- /* *
179
- * Licensed under the Apache License, Version 2.0 (the "License");
180
- * you may not use this file except in compliance with the License.
181
- * You may obtain a copy of the License at
182
- *
183
- * http://www.apache.org/licenses/LICENSE-2.0
184
- *
185
- * Unless required by applicable law or agreed to in writing, software
186
- * distributed under the License is distributed on an "AS IS" BASIS,
187
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
- * See the License for the specific language governing permissions and
189
- * limitations under the License.
190
- *
191
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
192
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
193
- * */
194
- var useTafSettings = function useTafSettings( // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
195
- tafConfig) {
196
- var locations = tafConfig.locations;
197
- return {
198
- locations: locations
199
- };
200
- };
201
-
202
- var location_indicator_mwo = "EHDB";
203
- var locations = {
204
- EHAM: {
205
- validity_duration: 30,
206
- activity_period: 6,
207
- label: "Schiphol"
208
- },
209
- EHRD: {
210
- validity_duration: 30,
211
- activity_period: 6,
212
- label: "Rotterdam"
213
- },
214
- EHGG: {
215
- validity_duration: 30,
216
- activity_period: 6,
217
- label: "Eelde"
218
- },
219
- EHBK: {
220
- validity_duration: 30,
221
- activity_period: 6,
222
- label: "Maastricht"
223
- },
224
- EHLE: {
225
- validity_duration: 30,
226
- activity_period: 6,
227
- label: "Lelystad"
228
- },
229
- TNCB: {
230
- validity_duration: 30,
231
- activity_period: 6,
232
- label: "Bonaire"
233
- }
234
- };
235
- var locationOrder = [
236
- "EHAM",
237
- "EHRD",
238
- "EHLE",
239
- "EHGG",
240
- "EHBK",
241
- "TNCB"
242
- ];
243
- var tafConfig = {
244
- location_indicator_mwo: location_indicator_mwo,
245
- locations: locations,
246
- locationOrder: locationOrder
247
- };
248
-
249
125
  /*! *****************************************************************************
250
126
  Copyright (c) Microsoft Corporation.
251
127
 
@@ -2516,6 +2392,7 @@ var getConfirmationDialogTitle = function getConfirmationDialogTitle(action) {
2516
2392
  if (action === 'PUBLISH') return 'Publish';
2517
2393
  if (action === 'AMEND') return 'This TAF is an amendment';
2518
2394
  if (action === 'CORRECT') return 'This TAF is a correction';
2395
+ if (action === 'CANCEL') return 'Cancel TAF';
2519
2396
  return 'Cancel TAF';
2520
2397
  }; // Check if the amended/corrected TAF has been changed. Only compare the fields users are able to fill in
2521
2398
  // (i.e. exclude baseforecast valid time as that gets updated when doing an amendment automatically outside of the users influence)
@@ -2557,90 +2434,176 @@ var getConfirmationDialogButtonLabel = function getConfirmationDialogButtonLabel
2557
2434
  return 'Discard';
2558
2435
  }
2559
2436
 
2437
+ case 'CANCEL':
2438
+ return 'Cancel';
2439
+
2560
2440
  default:
2561
2441
  {
2562
2442
  return 'Publish';
2563
2443
  }
2564
2444
  }
2565
2445
  };
2446
+ var emptyChangegroup = {
2447
+ valid: '',
2448
+ wind: '',
2449
+ visibility: '',
2450
+ weather: {
2451
+ weather1: null,
2452
+ weather2: null,
2453
+ weather3: null
2454
+ },
2455
+ cloud: {
2456
+ cloud1: null,
2457
+ cloud2: null,
2458
+ cloud3: null,
2459
+ cloud4: null
2460
+ },
2461
+ change: null,
2462
+ probability: null
2463
+ };
2464
+ var getTafStatusLabel = function getTafStatusLabel(status) {
2465
+ switch (status) {
2466
+ case 'DRAFT_AMENDED':
2467
+ return 'draft amended';
2566
2468
 
2567
- var getTafErrors = function getTafErrors(name, errors) {
2568
- var nameAsArray = name.split('.');
2469
+ case 'DRAFT_CORRECTED':
2470
+ return 'draft corrected';
2569
2471
 
2570
- if (nameAsArray[0].includes('changeGroups')) {
2571
- if (errors.changeGroups) {
2572
- var changeGroupNum = nameAsArray[0].slice(13, nameAsArray[0].length - 1);
2573
- var restArray = nameAsArray.slice(1);
2574
- return getDeepProperty(restArray, errors.changeGroups[changeGroupNum]);
2575
- } // No changegroup errors
2472
+ default:
2473
+ return status.toLocaleLowerCase();
2474
+ }
2475
+ };
2476
+ var getMessageType = function getMessageType(taf, tafAction) {
2477
+ if (tafAction === 'CORRECT') {
2478
+ return 'COR';
2479
+ }
2576
2480
 
2481
+ if (tafAction === 'AMEND') {
2482
+ return 'AMD';
2483
+ }
2577
2484
 
2578
- return null;
2485
+ return taf.messageType;
2486
+ }; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
2487
+
2488
+ var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafAction) {
2489
+ var previousValidDateStart = taf.previousValidDateStart && tafAction !== 'AMEND' ? taf.previousValidDateStart : taf.validDateStart;
2490
+ var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== 'AMEND' ? taf.previousValidDateEnd : taf.validDateEnd; // For amendment change valid start time to current time
2491
+ // only do this if we're already within the validity period
2492
+
2493
+ if ((tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND') && moment.utc() >= moment.utc(taf.validDateStart)) {
2494
+ var now = moment.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
2495
+ var validObj = {
2496
+ start: now,
2497
+ end: taf.baseForecast.valid.end
2498
+ };
2499
+ return Object.assign(Object.assign({}, taf), {
2500
+ previousValidDateStart: previousValidDateStart,
2501
+ previousValidDateEnd: previousValidDateEnd,
2502
+ validDateStart: now,
2503
+ baseForecast: Object.assign(Object.assign({}, taf.baseForecast), {
2504
+ valid: validObj
2505
+ })
2506
+ });
2579
2507
  }
2580
2508
 
2581
- return getDeepProperty(nameAsArray, errors);
2509
+ return Object.assign(Object.assign({}, taf), {
2510
+ previousValidDateStart: previousValidDateStart,
2511
+ previousValidDateEnd: previousValidDateEnd
2512
+ });
2582
2513
  };
2583
-
2584
- var getDisplayValue = function getDisplayValue(value, disabled) {
2585
- return disabled && !value ? '-' : value;
2514
+ var prepareTafValues = function prepareTafValues(_taf, tafAction) {
2515
+ var addEmptyChangeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2516
+ // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
2517
+ // If action is AMEND/DRAFT_AMEND - update validity start time to current time
2518
+ var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
2519
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
2520
+ messageType: getMessageType(taf, tafAction),
2521
+ baseForecast: formatFormValues(taf.baseForecast)
2522
+ }), taf.changeGroups && {
2523
+ changeGroups: taf.changeGroups.map(formatFormValues)
2524
+ }), addEmptyChangeGroup && {
2525
+ changeGroups: [emptyChangegroup]
2526
+ });
2586
2527
  };
2587
- var useStyles$8 = makeStyles(function (theme) {
2528
+
2529
+ var textFieldStyle = function textFieldStyle(theme) {
2588
2530
  return {
2589
- textFieldInput: {
2590
- height: 46,
2591
- width: 56,
2531
+ // input
2532
+ marginRight: '2px',
2533
+ marginBottom: '4px',
2534
+ width: 56,
2535
+ height: 46,
2536
+ input: {
2592
2537
  textAlign: 'center',
2593
2538
  fontSize: 10,
2594
2539
  fontWeight: 500,
2595
2540
  paddingLeft: 0,
2596
2541
  paddingRight: 0,
2597
- marginBotom: '2px',
2598
2542
  '&.Mui-disabled': {
2599
- '-webkit-text-fill-color': theme.palette.geowebColors.typographyAndIcons.text,
2600
- color: theme.palette.geowebColors.typographyAndIcons.text,
2601
- '&:before': {
2602
- border: 'none'
2603
- }
2543
+ color: 'geowebColors.typographyAndIcons.text',
2544
+ WebkitTextFillColor: theme.palette.geowebColors.typographyAndIcons.text
2545
+ },
2546
+ // TODO: https://gitlab.com/opengeoweb/opengeoweb/-/issues/1995 disables the default autofill styling, should be a better fix
2547
+ '&:-webkit-autofill': {
2548
+ WebkitTransitionDelay: '86400s' // 1 day delay
2549
+
2604
2550
  }
2605
2551
  },
2606
- textFieldLabel: {
2552
+ label: {
2553
+ transformOrigin: 'center top',
2554
+ right: 0,
2555
+ textAlign: 'center',
2607
2556
  fontSize: '10px',
2608
2557
  '&.Mui-disabled': {
2609
- color: theme.palette.geowebColors.captions.captionStatus.rgba
2558
+ color: 'geowebColors.captions.captionStatus.rgba'
2610
2559
  },
2611
2560
  whiteSpace: 'nowrap',
2612
- maxWidth: '100%'
2561
+ maxWidth: '100%',
2562
+ transform: 'translate(0px, 16px) scale(1)'
2613
2563
  },
2614
- textFieldLabelShrink: {
2564
+ // shrink
2565
+ ' .MuiInputLabel-shrink': {
2615
2566
  transform: 'translate(2px, 10px) scale(0.75) !important',
2616
- letterSpacing: '0.33px'
2567
+ letterSpacing: '0.33px',
2568
+ textAlign: 'left'
2569
+ },
2570
+ // root
2571
+ '&': {
2572
+ '.Mui-disabled:before': {
2573
+ borderColor: 'transparent'
2574
+ }
2617
2575
  }
2618
2576
  };
2619
- });
2577
+ };
2578
+
2579
+ var getTafErrors = function getTafErrors(name, errors) {
2580
+ var nameAsArray = name.split('.');
2581
+
2582
+ if (nameAsArray[0].includes('changeGroups')) {
2583
+ if (errors.changeGroups) {
2584
+ var changeGroupNum = nameAsArray[0].slice(13, nameAsArray[0].length - 1);
2585
+ var restArray = nameAsArray.slice(1);
2586
+ return getDeepProperty(restArray, errors.changeGroups[changeGroupNum]);
2587
+ } // No changegroup errors
2588
+
2589
+
2590
+ return null;
2591
+ }
2592
+
2593
+ return getDeepProperty(nameAsArray, errors);
2594
+ };
2595
+
2596
+ var getDisplayValue = function getDisplayValue(value, disabled) {
2597
+ return disabled && !value ? '-' : value;
2598
+ };
2620
2599
  var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
2621
- var classes = useStyles$8();
2622
2600
  return /*#__PURE__*/React__default.createElement(TextField, Object.assign({
2623
2601
  type: "text",
2624
2602
  variant: "filled",
2625
- InputProps: {
2626
- classes: {
2627
- root: classes.textFieldInput,
2628
- input: classes.textFieldInput
2629
- }
2630
- },
2631
- InputLabelProps: {
2632
- classes: {
2633
- root: classes.textFieldLabel,
2634
- shrink: classes.textFieldLabelShrink
2635
- }
2636
- },
2637
- sx: {
2638
- marginRight: '2px',
2639
- marginBottom: '2px'
2640
- }
2603
+ sx: textFieldStyle
2641
2604
  }, props));
2642
2605
  }, function (prevProps, nextProps) {
2643
- return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name;
2606
+ return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name && prevProps.disabled === nextProps.disabled;
2644
2607
  });
2645
2608
 
2646
2609
  var TafFormTextField = function TafFormTextField(_ref) {
@@ -2868,7 +2831,8 @@ var TafFormOptionsButton = function TafFormOptionsButton(_ref) {
2868
2831
  return /*#__PURE__*/React.createElement(ToggleMenu, {
2869
2832
  buttonTestId: "tafFormOptions[".concat(index, "]"),
2870
2833
  buttonSx: {
2871
- margin: '14px 10px'
2834
+ marginTop: '10px',
2835
+ marginLeft: '4px'
2872
2836
  },
2873
2837
  menuItems: isChangeGroup ? menuItemsChangeGroup : menuItemsBaseForecast
2874
2838
  });
@@ -3043,13 +3007,14 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
3043
3007
  justifyContent: "flex-start",
3044
3008
  "data-testid": "row-".concat(namePrefix),
3045
3009
  container: true,
3046
- ref: ref
3010
+ ref: ref,
3011
+ columns: 24
3047
3012
  }, props), /*#__PURE__*/React__default.createElement(Grid, {
3048
3013
  item: true,
3049
- xs: 11
3050
- }, /*#__PURE__*/React__default.createElement(Grid, {
3051
3014
  container: true,
3052
- justifyContent: "flex-end"
3015
+ justifyContent: "flex-end",
3016
+ xs: 24,
3017
+ sm: 23
3053
3018
  }, !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
3054
3019
  label: "Type",
3055
3020
  name: fieldNames.messageType,
@@ -3306,9 +3271,16 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
3306
3271
  }
3307
3272
  }
3308
3273
  }
3309
- }))), !disabled && /*#__PURE__*/React__default.createElement(Grid, {
3274
+ })), !disabled && /*#__PURE__*/React__default.createElement(Grid, {
3310
3275
  item: true,
3311
- xs: 1
3276
+ container: true,
3277
+ justifyContent: "flex-end",
3278
+ alignItems: "flex-end",
3279
+ xs: 24,
3280
+ sm: 1,
3281
+ sx: {
3282
+ marginBottom: '16px'
3283
+ }
3312
3284
  }, /*#__PURE__*/React__default.createElement(TafFormOptionsButton, {
3313
3285
  isChangeGroup: isChangeGroup,
3314
3286
  addChangeGroupBelow: addChangeGroupBelow,
@@ -3337,54 +3309,182 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
3337
3309
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3338
3310
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
3339
3311
  * */
3340
-
3341
- var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3342
- switch (sumOfErrors) {
3343
- case 0:
3344
- return '0 issues';
3345
-
3346
- case 1:
3347
- return '1 issue';
3348
-
3349
- default:
3350
- return "".concat(sumOfErrors, " issues");
3351
- }
3352
- };
3353
-
3354
- var buttonColors = {
3355
- green: '#72bb23',
3356
- red: '#c00000'
3357
- };
3358
-
3359
- var buttonStyle = function buttonStyle(color) {
3360
- var buttonColor = buttonColors[color];
3361
- return {
3362
- width: '74px',
3363
- color: '#ffffff',
3364
- backgroundColor: buttonColor,
3365
- '&:hover': {
3366
- backgroundColor: buttonColor
3312
+ var buttonsStyle = {
3313
+ button: {
3314
+ minWidth: {
3315
+ xs: '56px',
3316
+ sm: '64px'
3367
3317
  },
3368
- '&:focus': {
3369
- backgroundColor: buttonColor
3318
+ width: {
3319
+ xs: '56px',
3320
+ sm: '64px'
3370
3321
  },
3371
- fontSize: 12
3372
- };
3322
+ marginLeft: {
3323
+ xs: 0.5,
3324
+ sm: 1
3325
+ },
3326
+ marginTop: 3,
3327
+ marginBottom: 3
3328
+ }
3373
3329
  };
3374
3330
 
3375
- var IssuesButton = function IssuesButton(_ref) {
3376
- var togglePane = _ref.togglePane,
3377
- sumOfErrors = _ref.sumOfErrors;
3378
- var color = sumOfErrors > 0 ? 'red' : 'green';
3379
- return /*#__PURE__*/React.createElement(Tooltip, {
3380
- title: "View details"
3381
- }, /*#__PURE__*/React.createElement(Chip, {
3382
- "data-testid": "issuesButton",
3383
- size: "small",
3384
- label: getIssuesLabel(sumOfErrors),
3385
- style: Object.assign({}, buttonStyle(color)),
3386
- onClick: togglePane
3387
- }));
3331
+ var ViewModeButtons = function ViewModeButtons(_ref) {
3332
+ var canBe = _ref.canBe,
3333
+ onTafViewModeButtonPress = _ref.onTafViewModeButtonPress;
3334
+ return !canBe.includes('CANCELLED') && !canBe.includes('CORRECTED') && !canBe.includes('AMENDED') ? null : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, canBe.includes('CANCELLED') && /*#__PURE__*/React__default.createElement(Button, {
3335
+ "data-testid": "canceltaf",
3336
+ variant: "tertiary",
3337
+ onClick: function onClick() {
3338
+ return onTafViewModeButtonPress('CANCEL');
3339
+ }
3340
+ }, "Cancel"), canBe.includes('CORRECTED') && /*#__PURE__*/React__default.createElement(Button, {
3341
+ "data-testid": "correctaf",
3342
+ variant: "tertiary",
3343
+ onClick: function onClick() {
3344
+ return onTafViewModeButtonPress('CORRECT');
3345
+ }
3346
+ }, "Correct"), canBe.includes('AMENDED') && /*#__PURE__*/React__default.createElement(Button, {
3347
+ "data-testid": "amendtaf",
3348
+ variant: "tertiary",
3349
+ onClick: function onClick() {
3350
+ return onTafViewModeButtonPress('AMEND');
3351
+ }
3352
+ }, "Amend"));
3353
+ };
3354
+
3355
+ var TafFormButtons = function TafFormButtons(_ref2) {
3356
+ var _ref2$isFormDisabled = _ref2.isFormDisabled,
3357
+ isFormDisabled = _ref2$isFormDisabled === void 0 ? false : _ref2$isFormDisabled,
3358
+ tafAction = _ref2.tafAction,
3359
+ _ref2$canBe = _ref2.canBe,
3360
+ canBe = _ref2$canBe === void 0 ? [] : _ref2$canBe,
3361
+ onTafEditModeButtonPress = _ref2.onTafEditModeButtonPress,
3362
+ onTafViewModeButtonPress = _ref2.onTafViewModeButtonPress;
3363
+ return /*#__PURE__*/React__default.createElement(Grid, {
3364
+ container: true,
3365
+ justifyContent: "flex-end",
3366
+ sx: buttonsStyle,
3367
+ columns: 24
3368
+ }, /*#__PURE__*/React__default.createElement(Grid, {
3369
+ item: true,
3370
+ container: true,
3371
+ justifyContent: "flex-end",
3372
+ xs: 24,
3373
+ sm: 23
3374
+ }, isFormDisabled ? /*#__PURE__*/React__default.createElement(ViewModeButtons, {
3375
+ canBe: canBe,
3376
+ onTafViewModeButtonPress: onTafViewModeButtonPress
3377
+ }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
3378
+ "data-testid": "discardtaf",
3379
+ variant: "tertiary",
3380
+ onClick: function onClick() {
3381
+ // Simply discard the changes and close the dialog.
3382
+ onTafEditModeButtonPress('DISCARD');
3383
+ }
3384
+ }, "Discard"), /*#__PURE__*/React__default.createElement(Button, {
3385
+ "data-testid": "savedrafttaf",
3386
+ variant: "tertiary",
3387
+ onClick: function onClick() {
3388
+ /* Save the TAF as draft:
3389
+ if action NEW or DRAFT - new status will be DRAFT -- default
3390
+ if action AMEND - new status will be DRAFT_AMENDED
3391
+ if action CORRECT - new status will be DRAFT_CORRECTED
3392
+ if action DRAFT_AMEND - new status will be DRAFT_AMENDED
3393
+ if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
3394
+ */
3395
+ switch (tafAction) {
3396
+ case 'AMEND':
3397
+ case 'DRAFT_AMEND':
3398
+ onTafEditModeButtonPress('DRAFT_AMEND');
3399
+ break;
3400
+
3401
+ case 'CORRECT':
3402
+ case 'DRAFT_CORRECT':
3403
+ onTafEditModeButtonPress('DRAFT_CORRECT');
3404
+ break;
3405
+
3406
+ default:
3407
+ onTafEditModeButtonPress('DRAFT');
3408
+ break;
3409
+ }
3410
+ }
3411
+ }, "Save"), /*#__PURE__*/React__default.createElement(Button, {
3412
+ "data-testid": "publishtaf",
3413
+ variant: "tertiary",
3414
+ onClick: function onClick() {
3415
+ /* Publish the TAF:
3416
+ if action NEW or DRAFT - new status will be PUBLISHED -- default
3417
+ if action AMEND - new status will be AMENDED
3418
+ if action CORRECT - new status will be CORRECTED
3419
+ if action DRAFT_AMEND - new status will be AMENDED
3420
+ if action DRAFT_CORRECT - new status will be CORRECTED
3421
+ */
3422
+ switch (tafAction) {
3423
+ case 'AMEND':
3424
+ case 'DRAFT_AMEND':
3425
+ onTafEditModeButtonPress('AMEND');
3426
+ break;
3427
+
3428
+ case 'CORRECT':
3429
+ case 'DRAFT_CORRECT':
3430
+ onTafEditModeButtonPress('CORRECT');
3431
+ break;
3432
+
3433
+ default:
3434
+ onTafEditModeButtonPress('PUBLISH');
3435
+ break;
3436
+ }
3437
+ }
3438
+ }, "Publish"))), /*#__PURE__*/React__default.createElement(Grid, {
3439
+ item: true,
3440
+ sm: 1
3441
+ }));
3442
+ };
3443
+
3444
+ /* *
3445
+ * Licensed under the Apache License, Version 2.0 (the "License");
3446
+ * you may not use this file except in compliance with the License.
3447
+ * You may obtain a copy of the License at
3448
+ *
3449
+ * http://www.apache.org/licenses/LICENSE-2.0
3450
+ *
3451
+ * Unless required by applicable law or agreed to in writing, software
3452
+ * distributed under the License is distributed on an "AS IS" BASIS,
3453
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3454
+ * See the License for the specific language governing permissions and
3455
+ * limitations under the License.
3456
+ *
3457
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3458
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
3459
+ * */
3460
+ var useStyles = makeStyles(function () {
3461
+ return {
3462
+ dragHandle: {
3463
+ backgroundColor: 'transparent',
3464
+ '&:hover': {
3465
+ backgroundColor: 'transparent'
3466
+ },
3467
+ cursor: function cursor(isSorting) {
3468
+ return isSorting ? 'grabbing' : 'grab';
3469
+ }
3470
+ }
3471
+ };
3472
+ });
3473
+
3474
+ var DragHandle = function DragHandle(_ref) {
3475
+ var _ref$isSorting = _ref.isSorting,
3476
+ isSorting = _ref$isSorting === void 0 ? false : _ref$isSorting,
3477
+ _ref$isDisabled = _ref.isDisabled,
3478
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
3479
+ index = _ref.index;
3480
+ var classes = useStyles(isSorting);
3481
+ return /*#__PURE__*/React__default.createElement(IconButton, {
3482
+ className: "".concat(classes.dragHandle, " handle"),
3483
+ "data-testid": "dragHandle-".concat(index),
3484
+ disableRipple: true,
3485
+ disabled: isDisabled,
3486
+ size: "large"
3487
+ }, /*#__PURE__*/React__default.createElement(DragIndicator, null));
3388
3488
  };
3389
3489
 
3390
3490
  /* *
@@ -3424,32 +3524,6 @@ var ThumbsUp = function ThumbsUp(props) {
3424
3524
  })));
3425
3525
  };
3426
3526
 
3427
- /* *
3428
- * Licensed under the Apache License, Version 2.0 (the "License");
3429
- * you may not use this file except in compliance with the License.
3430
- * You may obtain a copy of the License at
3431
- *
3432
- * http://www.apache.org/licenses/LICENSE-2.0
3433
- *
3434
- * Unless required by applicable law or agreed to in writing, software
3435
- * distributed under the License is distributed on an "AS IS" BASIS,
3436
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3437
- * See the License for the specific language governing permissions and
3438
- * limitations under the License.
3439
- *
3440
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3441
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3442
- * */
3443
- var useStyles$7 = makeStyles({
3444
- paneContent: {
3445
- marginTop: '16px',
3446
- marginLeft: '24px'
3447
- },
3448
- image: {
3449
- fontSize: '4rem'
3450
- }
3451
- });
3452
-
3453
3527
  var getPaneTitle = function getPaneTitle(sumOfErrors) {
3454
3528
  switch (sumOfErrors) {
3455
3529
  case 0:
@@ -3488,7 +3562,7 @@ var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
3488
3562
  var nameWithoutBrackets = nameAsString.replace(/[[\]']+/g, '');
3489
3563
  var nameLowerCase = nameWithoutBrackets.toLowerCase();
3490
3564
 
3491
- var _nameLowerCase$split$ = nameLowerCase.split(/([0-9]+)/) // split numbers from field and build array
3565
+ var _nameLowerCase$split$ = nameLowerCase.split(/([0-9]+)/) // split num bers from field and build array
3492
3566
  .filter(function (s) {
3493
3567
  return s.length;
3494
3568
  }),
@@ -3516,33 +3590,43 @@ var getErrorMessage = function getErrorMessage(error, index) {
3516
3590
  var fieldErrorTitle = humanizeErrorMessage(firstNamePart);
3517
3591
  return "".concat(index + 1, ". ").concat(fieldErrorTitle, ": ").concat(getErrorDefaultMessage(error));
3518
3592
  };
3593
+ var MODAL_DIALOG_ELEMENT = 'modal-dialog';
3519
3594
 
3520
3595
  var IssuesPane = function IssuesPane(_ref3) {
3521
3596
  var isOpen = _ref3.isOpen,
3522
3597
  handleClose = _ref3.handleClose,
3523
3598
  _ref3$errorList = _ref3.errorList,
3524
- errorList = _ref3$errorList === void 0 ? [] : _ref3$errorList;
3525
- var classes = useStyles$7();
3526
- return /*#__PURE__*/React.createElement(ToolContainerDraggable, {
3599
+ errorList = _ref3$errorList === void 0 ? [] : _ref3$errorList,
3600
+ _ref3$startPosition = _ref3.startPosition,
3601
+ startPosition = _ref3$startPosition === void 0 ? {
3602
+ left: 20,
3603
+ top: 50
3604
+ } : _ref3$startPosition;
3605
+ var rootElement = document.getElementById(MODAL_DIALOG_ELEMENT) || document.body;
3606
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(ToolContainerDraggable, {
3527
3607
  startSize: {
3528
3608
  width: '577px',
3529
3609
  height: '200px'
3530
3610
  },
3531
- startPosition: {
3532
- right: 20,
3533
- top: 50
3534
- },
3611
+ startPosition: startPosition,
3535
3612
  minWidth: 300,
3536
3613
  onClose: handleClose,
3537
3614
  title: getPaneTitle(errorList.length),
3538
3615
  headerSize: "xs",
3539
3616
  isOpen: isOpen,
3540
3617
  "data-testid": "moveable-issues-pane",
3541
- bounds: "body"
3542
- }, /*#__PURE__*/React.createElement("div", {
3543
- className: classes.paneContent
3544
- }, errorList.length === 0 && /*#__PURE__*/React.createElement("div", {
3545
- className: classes.image,
3618
+ bounds: "parent"
3619
+ }, /*#__PURE__*/React.createElement(Box, {
3620
+ component: "div",
3621
+ sx: {
3622
+ marginTop: '16px',
3623
+ marginLeft: '24px'
3624
+ }
3625
+ }, errorList.length === 0 && /*#__PURE__*/React.createElement(Box, {
3626
+ component: "div",
3627
+ sx: {
3628
+ fontSize: '4rem'
3629
+ },
3546
3630
  "data-testid": "zeroIssuesImage"
3547
3631
  }, /*#__PURE__*/React.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3548
3632
  return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
@@ -3552,7 +3636,7 @@ var IssuesPane = function IssuesPane(_ref3) {
3552
3636
  variant: "body1",
3553
3637
  "data-testid": "errorMessage"
3554
3638
  }, getErrorMessage(error, index));
3555
- })));
3639
+ }))), rootElement);
3556
3640
  };
3557
3641
 
3558
3642
  var getCustomError = function getCustomError(error) {
@@ -3566,6 +3650,19 @@ var getCustomError = function getCustomError(error) {
3566
3650
  });
3567
3651
  };
3568
3652
 
3653
+ var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3654
+ switch (sumOfErrors) {
3655
+ case 0:
3656
+ return '0 issues';
3657
+
3658
+ case 1:
3659
+ return '1 issue';
3660
+
3661
+ default:
3662
+ return "".concat(sumOfErrors, " issues");
3663
+ }
3664
+ };
3665
+
3569
3666
  var getErrorValues = function getErrorValues(fieldErrors) {
3570
3667
  if (!fieldErrors) return [];
3571
3668
  return Object.keys(fieldErrors).reduce(function (list, key) {
@@ -3579,22 +3676,6 @@ var getErrorValues = function getErrorValues(fieldErrors) {
3579
3676
  }, []);
3580
3677
  };
3581
3678
 
3582
- var getErrors = function getErrors(errors) {
3583
- var errorList = Object.keys(errors).reduce(function (list, key) {
3584
- var errorValue = errors[key];
3585
-
3586
- if (Array.isArray(errorValue)) {
3587
- var errorValues = errorValue.reduce(function (l, i) {
3588
- return l.concat(getErrorValues(i));
3589
- }, []);
3590
- return list.concat.apply(list, _toConsumableArray(errorValues));
3591
- }
3592
-
3593
- return list.concat(getErrorValues(errorValue));
3594
- }, []);
3595
- return errorList;
3596
- };
3597
-
3598
3679
  var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3599
3680
  return errors.reduce(function (list, error) {
3600
3681
  // check on type validateRequiredSub and validateRequiredMainOptional since these are giving 'duplicates'
@@ -3617,16 +3698,31 @@ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3617
3698
  }, []);
3618
3699
  };
3619
3700
 
3620
- var TafFormButtons = function TafFormButtons(_ref) {
3621
- var tafAction = _ref.tafAction,
3622
- onTafFormButtonPress = _ref.onTafFormButtonPress;
3701
+ var getErrors = function getErrors(errors) {
3702
+ var errorList = Object.keys(errors).reduce(function (list, key) {
3703
+ var errorValue = errors[key];
3623
3704
 
3624
- var _useFormContext = useFormContext(),
3625
- errors = _useFormContext.errors;
3705
+ if (Array.isArray(errorValue)) {
3706
+ var errorValues = errorValue.reduce(function (l, i) {
3707
+ return l.concat(getErrorValues(i));
3708
+ }, []);
3709
+ return list.concat.apply(list, _toConsumableArray(errorValues));
3710
+ }
3711
+
3712
+ return list.concat(getErrorValues(errorValue));
3713
+ }, []);
3714
+ return errorList;
3715
+ };
3626
3716
 
3717
+ var IssuesButton = function IssuesButton(_ref) {
3718
+ var _ref$errors = _ref.errors,
3719
+ errors = _ref$errors === void 0 ? {} : _ref$errors;
3627
3720
  var errorList = filterDuplicateErrors(getErrors(errors));
3721
+ var totalErrors = errorList.length;
3722
+ var errorStatus = totalErrors > 0 ? 'error' : 'success';
3723
+ var buttonColor = "geowebColors.functional.".concat(errorStatus);
3628
3724
 
3629
- var _React$useState = React__default.useState(false),
3725
+ var _React$useState = React.useState(false),
3630
3726
  _React$useState2 = _slicedToArray(_React$useState, 2),
3631
3727
  isIssuesPaneOpen = _React$useState2[0],
3632
3728
  setIsIssuesPaneOpen = _React$useState2[1];
@@ -3635,223 +3731,66 @@ var TafFormButtons = function TafFormButtons(_ref) {
3635
3731
  return setIsIssuesPaneOpen(!isIssuesPaneOpen);
3636
3732
  };
3637
3733
 
3638
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
3639
- container: true,
3640
- justifyContent: "space-between",
3641
- alignItems: "center",
3642
- sx: {
3643
- margin: '10px 0px 22px 0px'
3644
- }
3645
- }, /*#__PURE__*/React__default.createElement(Grid, {
3646
- item: true
3647
- }, /*#__PURE__*/React__default.createElement(IssuesButton, {
3648
- sumOfErrors: errorList.length,
3649
- togglePane: toggleIssuesPane
3650
- }))), /*#__PURE__*/React__default.createElement(Grid, {
3651
- container: true,
3652
- justifyContent: "flex-end",
3653
- sx: {
3654
- paddingRight: '28px'
3655
- }
3656
- }, /*#__PURE__*/React__default.createElement(Grid, {
3657
- item: true
3658
- }, /*#__PURE__*/React__default.createElement(Button, {
3659
- "data-testid": "discardtaf",
3660
- variant: "tertiary",
3661
- onClick: function onClick() {
3662
- // Simply discard the changes and close the dialog.
3663
- onTafFormButtonPress('DISCARD');
3664
- }
3665
- }, "Discard"), /*#__PURE__*/React__default.createElement(Button, {
3666
- "data-testid": "savedrafttaf",
3667
- variant: "tertiary",
3668
- sx: {
3669
- margin: '0px 10px'
3670
- },
3671
- onClick: function onClick() {
3672
- /* Save the TAF as draft:
3673
- if action NEW or DRAFT - new status will be DRAFT -- default
3674
- if action AMEND - new status will be DRAFT_AMENDED
3675
- if action CORRECT - new status will be DRAFT_CORRECTED
3676
- if action DRAFT_AMEND - new status will be DRAFT_AMENDED
3677
- if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
3678
- */
3679
- switch (tafAction) {
3680
- case 'AMEND':
3681
- case 'DRAFT_AMEND':
3682
- onTafFormButtonPress('DRAFT_AMEND');
3683
- break;
3734
+ var _React$useState3 = React.useState({
3735
+ left: 0,
3736
+ top: 0
3737
+ }),
3738
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
3739
+ startPosition = _React$useState4[0],
3740
+ setStartPosition = _React$useState4[1];
3684
3741
 
3685
- case 'CORRECT':
3686
- case 'DRAFT_CORRECT':
3687
- onTafFormButtonPress('DRAFT_CORRECT');
3688
- break;
3742
+ var onClickButton = function onClickButton(event) {
3743
+ var _a;
3689
3744
 
3690
- default:
3691
- onTafFormButtonPress('DRAFT');
3692
- break;
3693
- }
3694
- }
3695
- }, "Save"), /*#__PURE__*/React__default.createElement(Button, {
3696
- "data-testid": "publishtaf",
3697
- variant: "tertiary",
3698
- onClick: function onClick() {
3699
- /* Publish the TAF:
3700
- if action NEW or DRAFT - new status will be PUBLISHED -- default
3701
- if action AMEND - new status will be AMENDED
3702
- if action CORRECT - new status will be CORRECTED
3703
- if action DRAFT_AMEND - new status will be AMENDED
3704
- if action DRAFT_CORRECT - new status will be CORRECTED
3705
- */
3706
- switch (tafAction) {
3707
- case 'AMEND':
3708
- case 'DRAFT_AMEND':
3709
- onTafFormButtonPress('AMEND');
3710
- break;
3745
+ var _event$currentTarget$ = event.currentTarget.getBoundingClientRect(),
3746
+ left = _event$currentTarget$.left,
3747
+ top = _event$currentTarget$.top;
3711
3748
 
3712
- case 'CORRECT':
3713
- case 'DRAFT_CORRECT':
3714
- onTafFormButtonPress('CORRECT');
3715
- break;
3749
+ var parentOffset = ((_a = document.getElementById('tafmodule')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
3750
+ top: 0,
3751
+ left: 0
3752
+ };
3753
+ var newPosition = {
3754
+ left: left - parentOffset.left + 100,
3755
+ top: top - parentOffset.top
3756
+ };
3757
+ setStartPosition(newPosition);
3758
+ toggleIssuesPane();
3759
+ };
3716
3760
 
3717
- default:
3718
- onTafFormButtonPress('PUBLISH');
3719
- break;
3720
- }
3721
- }
3722
- }, "Publish"))), /*#__PURE__*/React__default.createElement(IssuesPane, {
3723
- errorList: errorList,
3724
- handleClose: toggleIssuesPane,
3725
- isOpen: isIssuesPaneOpen
3726
- }));
3727
- };
3728
-
3729
- /* *
3730
- * Licensed under the Apache License, Version 2.0 (the "License");
3731
- * you may not use this file except in compliance with the License.
3732
- * You may obtain a copy of the License at
3733
- *
3734
- * http://www.apache.org/licenses/LICENSE-2.0
3735
- *
3736
- * Unless required by applicable law or agreed to in writing, software
3737
- * distributed under the License is distributed on an "AS IS" BASIS,
3738
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3739
- * See the License for the specific language governing permissions and
3740
- * limitations under the License.
3741
- *
3742
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3743
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3744
- * */
3745
- var useStyles$6 = makeStyles(function () {
3746
- return {
3747
- dragHandle: {
3748
- backgroundColor: 'transparent',
3761
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
3762
+ title: "View details"
3763
+ }, /*#__PURE__*/React.createElement(Chip, {
3764
+ "data-testid": "issuesButton",
3765
+ className: "status-".concat(errorStatus),
3766
+ size: "small",
3767
+ label: getIssuesLabel(totalErrors),
3768
+ onClick: onClickButton,
3769
+ sx: {
3770
+ width: '74px',
3771
+ color: '#ffffff',
3772
+ backgroundColor: buttonColor,
3749
3773
  '&:hover': {
3750
- backgroundColor: 'transparent'
3774
+ backgroundColor: buttonColor
3751
3775
  },
3752
- cursor: function cursor(isSorting) {
3753
- return isSorting ? 'grabbing' : 'grab';
3754
- }
3755
- }
3756
- };
3757
- });
3758
-
3759
- var DragHandle = function DragHandle(_ref) {
3760
- var _ref$isSorting = _ref.isSorting,
3761
- isSorting = _ref$isSorting === void 0 ? false : _ref$isSorting,
3762
- _ref$isDisabled = _ref.isDisabled,
3763
- isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
3764
- index = _ref.index;
3765
- var classes = useStyles$6(isSorting);
3766
- return /*#__PURE__*/React__default.createElement(IconButton, {
3767
- className: "".concat(classes.dragHandle, " handle"),
3768
- "data-testid": "dragHandle-".concat(index),
3769
- disableRipple: true,
3770
- disabled: isDisabled,
3771
- size: "large"
3772
- }, /*#__PURE__*/React__default.createElement(DragIndicator, null));
3773
- };
3774
-
3775
- /* *
3776
- * Licensed under the Apache License, Version 2.0 (the "License");
3777
- * you may not use this file except in compliance with the License.
3778
- * You may obtain a copy of the License at
3779
- *
3780
- * http://www.apache.org/licenses/LICENSE-2.0
3781
- *
3782
- * Unless required by applicable law or agreed to in writing, software
3783
- * distributed under the License is distributed on an "AS IS" BASIS,
3784
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3785
- * See the License for the specific language governing permissions and
3786
- * limitations under the License.
3787
- *
3788
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3789
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3790
- * */
3791
-
3792
- var TafListButtons = function TafListButtons(_ref) {
3793
- var uuid = _ref.uuid,
3794
- canBe = _ref.canBe,
3795
- onClickTafActionButton = _ref.onClickTafActionButton,
3796
- _ref$testId = _ref.testId,
3797
- testId = _ref$testId === void 0 ? 'taflist-canbebuttons' : _ref$testId;
3798
- return !canBe.includes('CANCELLED') && !canBe.includes('CORRECTED') && !canBe.includes('AMENDED') ? null : /*#__PURE__*/React__default.createElement(Grid, {
3799
- container: true,
3800
- justifyContent: "flex-end",
3801
- alignItems: "center",
3802
- "data-testid": testId,
3803
- sx: {
3804
- margin: '10px 0px 22px 0px',
3805
- paddingRight: '28px'
3806
- }
3807
- }, canBe.includes('CANCELLED') && /*#__PURE__*/React__default.createElement(Button, {
3808
- "data-testid": "canceltaf",
3809
- variant: "tertiary",
3810
- onClick: function onClick() {
3811
- return onClickTafActionButton('CANCEL', uuid);
3812
- }
3813
- }, "Cancel"), canBe.includes('CORRECTED') && /*#__PURE__*/React__default.createElement(Button, {
3814
- "data-testid": "correctaf",
3815
- variant: "tertiary",
3816
- sx: {
3817
- margin: '0px 10px'
3818
- },
3819
- onClick: function onClick() {
3820
- return onClickTafActionButton('CORRECT', uuid);
3821
- }
3822
- }, "Correct"), canBe.includes('AMENDED') && /*#__PURE__*/React__default.createElement(Button, {
3823
- "data-testid": "amendtaf",
3824
- variant: "tertiary",
3825
- onClick: function onClick() {
3826
- return onClickTafActionButton('AMEND', uuid);
3776
+ '&:focus': {
3777
+ backgroundColor: buttonColor
3778
+ },
3779
+ fontSize: 12
3827
3780
  }
3828
- }, "Amend"));
3781
+ })), /*#__PURE__*/React.createElement(IssuesPane, {
3782
+ errorList: errorList,
3783
+ handleClose: toggleIssuesPane,
3784
+ isOpen: isIssuesPaneOpen,
3785
+ startPosition: startPosition
3786
+ }));
3829
3787
  };
3830
3788
 
3831
3789
  var noop = function noop() {};
3832
3790
 
3833
- var emptyChangegroup = {
3834
- valid: '',
3835
- wind: '',
3836
- visibility: '',
3837
- weather: {
3838
- weather1: null,
3839
- weather2: null,
3840
- weather3: null
3841
- },
3842
- cloud: {
3843
- cloud1: null,
3844
- cloud2: null,
3845
- cloud3: null,
3846
- cloud4: null
3847
- },
3848
- change: null,
3849
- probability: null
3850
- };
3851
-
3852
3791
  var TafForm = function TafForm(_ref) {
3853
- var isDisabled = _ref.isDisabled,
3854
- tafAction = _ref.tafAction,
3792
+ var defaultTafAction = _ref.tafAction,
3793
+ isDefaultDisabled = _ref.isDisabled,
3855
3794
  _ref$staticTAC = _ref.staticTAC,
3856
3795
  staticTAC = _ref$staticTAC === void 0 ? '' : _ref$staticTAC,
3857
3796
  tafFromBackend = _ref.tafFromBackend,
@@ -3860,6 +3799,17 @@ var TafForm = function TafForm(_ref) {
3860
3799
  return null;
3861
3800
  } : _ref$onFormAction;
3862
3801
  var originalTaf = tafFromBackend.taf;
3802
+
3803
+ var _React$useState = React__default.useState(defaultTafAction),
3804
+ _React$useState2 = _slicedToArray(_React$useState, 2),
3805
+ tafAction = _React$useState2[0],
3806
+ setTafAction = _React$useState2[1];
3807
+
3808
+ var _React$useState3 = React__default.useState(isDefaultDisabled),
3809
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
3810
+ isDisabled = _React$useState4[0],
3811
+ setIsDisabled = _React$useState4[1];
3812
+
3863
3813
  var confirmDialog = useConfirmationDialog();
3864
3814
 
3865
3815
  var _useDraftFormHelpers = useDraftFormHelpers(),
@@ -3879,17 +3829,18 @@ var TafForm = function TafForm(_ref) {
3879
3829
  trigger = _useFormContext.trigger,
3880
3830
  formState = _useFormContext.formState,
3881
3831
  getValues = _useFormContext.getValues,
3882
- setValue = _useFormContext.setValue;
3832
+ setValue = _useFormContext.setValue,
3833
+ reset = _useFormContext.reset;
3883
3834
 
3884
3835
  var isFormDirty = formState.isDirty,
3885
3836
  errors = formState.errors;
3886
3837
  usePreventBrowserClose(isFormDirty && !isDisabled);
3887
3838
  var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
3888
3839
 
3889
- var _React$useState = React__default.useState(watch()),
3890
- _React$useState2 = _slicedToArray(_React$useState, 2),
3891
- delayedFormValues = _React$useState2[0],
3892
- setDelayedFormValues = _React$useState2[1];
3840
+ var _React$useState5 = React__default.useState(watch()),
3841
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
3842
+ delayedFormValues = _React$useState6[0],
3843
+ setDelayedFormValues = _React$useState6[1];
3893
3844
 
3894
3845
  var _useTACGenerator = useTACGenerator(convertTafValuesToObject(delayedFormValues), api.getTAC, staticTAC),
3895
3846
  _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
@@ -3932,7 +3883,23 @@ var TafForm = function TafForm(_ref) {
3932
3883
  });
3933
3884
  };
3934
3885
 
3935
- var onTafButtonPress = function onTafButtonPress(action) {
3886
+ var resetFormValues = function resetFormValues() {
3887
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
3888
+ var shouldAddEmptyChangGroup = arguments.length > 1 ? arguments[1] : undefined;
3889
+ var newTaf = prepareTafValues(tafFromBackend.taf, action, shouldAddEmptyChangGroup);
3890
+ reset(newTaf);
3891
+ };
3892
+
3893
+ var resetForm = function resetForm() {
3894
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
3895
+ var resetDisabled = arguments.length > 1 ? arguments[1] : undefined;
3896
+ var shouldAddEmptyChangGroup = !(tafFromBackend.taf && tafFromBackend.taf.changeGroups) && !resetDisabled;
3897
+ resetFormValues(action, shouldAddEmptyChangGroup);
3898
+ setIsDisabled(resetDisabled);
3899
+ setTafAction(action);
3900
+ };
3901
+
3902
+ var onTafEditModeButtonPress = function onTafEditModeButtonPress(action) {
3936
3903
  switch (action) {
3937
3904
  case 'DRAFT':
3938
3905
  case 'DRAFT_AMEND':
@@ -3946,10 +3913,10 @@ var TafForm = function TafForm(_ref) {
3946
3913
  case 'DISCARD':
3947
3914
  if (isFormDirty) {
3948
3915
  showConfirmDialog(action).then(function () {
3949
- onFormAction(action);
3916
+ resetForm(undefined, isDefaultDisabled);
3950
3917
  });
3951
3918
  } else {
3952
- onFormAction(action);
3919
+ resetForm(undefined, isDefaultDisabled);
3953
3920
  }
3954
3921
 
3955
3922
  break;
@@ -3959,9 +3926,35 @@ var TafForm = function TafForm(_ref) {
3959
3926
  case 'PUBLISH':
3960
3927
  toggleIsDraft(false);
3961
3928
  handleSubmit(function (data) {
3962
- showConfirmDialog(action).then(function () {
3963
- onFormAction(action, convertTafValuesToObject(data));
3964
- });
3929
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3930
+ var didSucceed;
3931
+ return regeneratorRuntime.wrap(function _callee$(_context) {
3932
+ while (1) {
3933
+ switch (_context.prev = _context.next) {
3934
+ case 0:
3935
+ _context.next = 2;
3936
+ return showConfirmDialog(action);
3937
+
3938
+ case 2:
3939
+ _context.next = 4;
3940
+ return onFormAction(action, convertTafValuesToObject(data));
3941
+
3942
+ case 4:
3943
+ didSucceed = _context.sent;
3944
+
3945
+ if (didSucceed) {
3946
+ setIsDisabled(true);
3947
+ reset(prepareTafValues(convertTafValuesToObject(data), action, false));
3948
+ setTafAction(null);
3949
+ }
3950
+
3951
+ case 6:
3952
+ case "end":
3953
+ return _context.stop();
3954
+ }
3955
+ }
3956
+ }, _callee);
3957
+ }));
3965
3958
  })();
3966
3959
  break;
3967
3960
 
@@ -3969,13 +3962,18 @@ var TafForm = function TafForm(_ref) {
3969
3962
  onFormAction(action);
3970
3963
  break;
3971
3964
  }
3972
- }; // TODO: https://gitlab.com/opengeoweb/opengeoweb/-/issues/1906 hookup actions
3973
-
3965
+ };
3974
3966
 
3975
3967
  var onTafViewModeButtonPress = function onTafViewModeButtonPress(action) {
3976
3968
  switch (action) {
3969
+ case 'CANCEL':
3970
+ showConfirmDialog(action).then(function () {
3971
+ onFormAction(action, tafFromBackend.taf);
3972
+ });
3973
+ break;
3974
+
3977
3975
  default:
3978
- onFormAction(action);
3976
+ resetForm(action, false);
3979
3977
  break;
3980
3978
  }
3981
3979
  };
@@ -4078,7 +4076,8 @@ var TafForm = function TafForm(_ref) {
4078
4076
  }, /*#__PURE__*/React__default.createElement(Typography, {
4079
4077
  sx: {
4080
4078
  fontSize: '20px',
4081
- fontWeight: 500
4079
+ fontWeight: 500,
4080
+ height: '24px'
4082
4081
  }
4083
4082
  }, "TAC"), /*#__PURE__*/React__default.createElement(Typography, {
4084
4083
  sx: {
@@ -4093,7 +4092,8 @@ var TafForm = function TafForm(_ref) {
4093
4092
  "data-testid": "tafform-tac-message-line",
4094
4093
  sx: {
4095
4094
  textIndent: '-0.7em',
4096
- borderRadius: '3px'
4095
+ borderRadius: '3px',
4096
+ paddingRight: '0.7em'
4097
4097
  }
4098
4098
  }, line);
4099
4099
  })), /*#__PURE__*/React__default.createElement(TafFormRow, {
@@ -4135,15 +4135,24 @@ var TafForm = function TafForm(_ref) {
4135
4135
  index: index
4136
4136
  })
4137
4137
  });
4138
- })), // TODO: these buttons should be combined, and the Issuesbuton should be separate
4139
- !isDisabled ? /*#__PURE__*/React__default.createElement(TafFormButtons, {
4138
+ })), !isDisabled && /*#__PURE__*/React__default.createElement(Grid, {
4139
+ container: true,
4140
+ justifyContent: "space-between",
4141
+ alignItems: "center",
4142
+ sx: {
4143
+ marginLeft: 1.5,
4144
+ marginTop: 1
4145
+ }
4146
+ }, /*#__PURE__*/React__default.createElement(Grid, {
4147
+ item: true
4148
+ }, /*#__PURE__*/React__default.createElement(IssuesButton, {
4149
+ errors: errors
4150
+ }))), /*#__PURE__*/React__default.createElement(TafFormButtons, {
4151
+ isFormDisabled: isDisabled,
4140
4152
  tafAction: tafAction,
4141
- onTafFormButtonPress: onTafButtonPress
4142
- }) : /*#__PURE__*/React__default.createElement(TafListButtons, {
4143
- uuid: originalTaf.uuid,
4144
4153
  canBe: tafFromBackend.canbe,
4145
- onClickTafActionButton: onTafViewModeButtonPress,
4146
- testId: "newtaflist-canbebuttons"
4154
+ onTafEditModeButtonPress: onTafEditModeButtonPress,
4155
+ onTafViewModeButtonPress: onTafViewModeButtonPress
4147
4156
  }), hiddenInputFields.map(function (field) {
4148
4157
  return /*#__PURE__*/React__default.createElement(ReactHookFormHiddenInput, {
4149
4158
  name: field,
@@ -4168,69 +4177,17 @@ var TafForm = function TafForm(_ref) {
4168
4177
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4169
4178
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
4170
4179
  * */
4171
- var getMessageType = function getMessageType(taf, tafAction) {
4172
- if (tafAction === 'CORRECT') {
4173
- return 'COR';
4174
- }
4175
-
4176
- if (tafAction === 'AMEND') {
4177
- return 'AMD';
4178
- }
4179
-
4180
- return taf.messageType;
4181
- }; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
4182
-
4183
- var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafAction) {
4184
- var previousValidDateStart = taf.previousValidDateStart && tafAction !== 'AMEND' ? taf.previousValidDateStart : taf.validDateStart;
4185
- var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== 'AMEND' ? taf.previousValidDateEnd : taf.validDateEnd; // For amendment change valid start time to current time
4186
- // only do this if we're already within the validity period
4187
-
4188
- if ((tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND') && moment.utc() >= moment.utc(taf.validDateStart)) {
4189
- var now = moment.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
4190
- var validObj = {
4191
- start: now,
4192
- end: taf.baseForecast.valid.end
4193
- };
4194
- return Object.assign(Object.assign({}, taf), {
4195
- previousValidDateStart: previousValidDateStart,
4196
- previousValidDateEnd: previousValidDateEnd,
4197
- validDateStart: now,
4198
- baseForecast: Object.assign(Object.assign({}, taf.baseForecast), {
4199
- valid: validObj
4200
- })
4201
- });
4202
- }
4203
-
4204
- return Object.assign(Object.assign({}, taf), {
4205
- previousValidDateStart: previousValidDateStart,
4206
- previousValidDateEnd: previousValidDateEnd
4207
- });
4208
- };
4209
- var prepareTafValues = function prepareTafValues(_taf, tafAction) {
4210
- var addEmptyChangeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4211
- // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
4212
- // If action is AMEND/DRAFT_AMEND - update validity start time to current time
4213
- var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
4214
- return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
4215
- messageType: getMessageType(taf, tafAction),
4216
- baseForecast: formatFormValues(taf.baseForecast)
4217
- }), taf.changeGroups && {
4218
- changeGroups: taf.changeGroups.map(formatFormValues)
4219
- }), addEmptyChangeGroup && {
4220
- changeGroups: [emptyChangegroup]
4221
- });
4222
- };
4223
4180
 
4224
4181
  var TafFormWrapper = function TafFormWrapper(_ref) {
4225
4182
  var tafFromBackend = _ref.tafFromBackend,
4226
4183
  mode = _ref.mode,
4227
- tafAction = _ref.tafAction,
4228
4184
  _ref$TAC = _ref.TAC,
4229
4185
  TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
4230
- onFormAction = _ref.onFormAction;
4186
+ onFormAction = _ref.onFormAction,
4187
+ tafAction = _ref.tafAction;
4231
4188
  var taf = tafFromBackend.taf;
4232
4189
  var isDisabled = mode === 'view';
4233
- var defaultValues = prepareTafValues(taf, tafAction, !isDisabled && !taf.changeGroups);
4190
+ var defaultValues = prepareTafValues(taf, undefined, !isDisabled && !taf.changeGroups);
4234
4191
  var options = {
4235
4192
  defaultValues: defaultValues,
4236
4193
  mode: 'onTouched',
@@ -4241,84 +4198,13 @@ var TafFormWrapper = function TafFormWrapper(_ref) {
4241
4198
  options: options
4242
4199
  }, /*#__PURE__*/React__default.createElement(TafForm, {
4243
4200
  isDisabled: isDisabled,
4244
- tafAction: tafAction,
4245
4201
  staticTAC: TAC,
4246
4202
  onFormAction: onFormAction,
4247
- tafFromBackend: tafFromBackend
4203
+ tafFromBackend: tafFromBackend,
4204
+ tafAction: tafAction
4248
4205
  }));
4249
4206
  };
4250
4207
 
4251
- var useStyles$5 = makeStyles({
4252
- dialogHeader: {
4253
- borderRadius: '3px',
4254
- border: 'solid 1px #f6f5f5',
4255
- zIndex: 1,
4256
- padding: '16px 20px'
4257
- },
4258
- dialogTitle: {
4259
- display: 'flex',
4260
- alignItems: 'center'
4261
- },
4262
- dialogCloseButton: {
4263
- display: 'flex',
4264
- justifyContent: 'flex-end'
4265
- },
4266
- dialogChildren: {
4267
- display: 'flex',
4268
- padding: 20,
4269
- minHeight: 200,
4270
- minWidth: 400,
4271
- height: '100%'
4272
- }
4273
- });
4274
-
4275
- var ContentDialog = function ContentDialog(_a) {
4276
- var open = _a.open;
4277
- _a.toggleDialogStatus;
4278
- var titleComponent = _a.titleComponent,
4279
- children = _a.children;
4280
- _a.onClose;
4281
- var _a$alertBanner = _a.alertBanner,
4282
- alertBanner = _a$alertBanner === void 0 ? null : _a$alertBanner,
4283
- onFormAction = _a.onFormAction,
4284
- other = __rest(_a, ["open", "toggleDialogStatus", "titleComponent", "children", "onClose", "alertBanner", "onFormAction"]);
4285
-
4286
- var classes = useStyles$5();
4287
- return /*#__PURE__*/React.createElement(Dialog, Object.assign({
4288
- "data-testid": "contentDialog",
4289
- open: open,
4290
- onClose: function onClose() {
4291
- return onFormAction('CLOSE');
4292
- },
4293
- maxWidth: other.maxWidth ? other.maxWidth : 'lg',
4294
- PaperProps: {
4295
- style: {
4296
- position: 'inherit'
4297
- }
4298
- }
4299
- }, other), /*#__PURE__*/React.createElement(DialogTitle, {
4300
- className: classes.dialogHeader
4301
- }, /*#__PURE__*/React.createElement(Grid, {
4302
- container: true
4303
- }, /*#__PURE__*/React.createElement(Grid, {
4304
- item: true,
4305
- xs: 11,
4306
- className: classes.dialogTitle
4307
- }, titleComponent), /*#__PURE__*/React.createElement(Grid, {
4308
- item: true,
4309
- xs: true,
4310
- className: classes.dialogCloseButton
4311
- }, /*#__PURE__*/React.createElement(IconButton, {
4312
- "data-testid": "closeDialog",
4313
- size: "small",
4314
- onClick: function onClick() {
4315
- return onFormAction('CLOSE');
4316
- }
4317
- }, /*#__PURE__*/React.createElement(Close, null))))), alertBanner !== null && alertBanner, /*#__PURE__*/React.createElement(DialogContent, {
4318
- className: classes.dialogChildren
4319
- }, children));
4320
- };
4321
-
4322
4208
  /* *
4323
4209
  * Licensed under the Apache License, Version 2.0 (the "License");
4324
4210
  * you may not use this file except in compliance with the License.
@@ -4332,210 +4218,172 @@ var ContentDialog = function ContentDialog(_a) {
4332
4218
  * See the License for the specific language governing permissions and
4333
4219
  * limitations under the License.
4334
4220
  *
4335
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4336
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4221
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4222
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4337
4223
  * */
4338
4224
 
4339
- var getActiveStatus = function getActiveStatus(listType, className) {
4340
- return listType === 'ACTIVE' ? /*#__PURE__*/React__default.createElement(CheckCircle, {
4341
- "data-testid": "status-active",
4342
- className: className,
4343
- fontSize: "small"
4344
- }) : /*#__PURE__*/React__default.createElement(Schedule, {
4345
- "data-testid": "status-upcoming",
4346
- className: className,
4347
- fontSize: "small"
4348
- });
4349
- };
4350
-
4351
- var getStatusTagList = function getStatusTagList(taf) {
4352
- // do not return anything if status = 'NEW'
4353
- if (taf.status === 'NEW') return null;
4354
-
4355
- if (taf.status === 'CANCELLED') {
4356
- return /*#__PURE__*/React__default.createElement(StatusTag, {
4357
- content: "cancelled",
4358
- color: "red"
4359
- });
4360
- }
4361
-
4362
- return /*#__PURE__*/React__default.createElement(StatusTag, {
4363
- content: taf.status.toLowerCase(),
4364
- color: taf.status === 'EXPIRED' ? 'grey' : 'green'
4365
- });
4225
+ var TabPanel = function TabPanel(_a) {
4226
+ var children = _a.children,
4227
+ value = _a.value,
4228
+ index = _a.index,
4229
+ other = __rest(_a, ["children", "value", "index"]);
4230
+
4231
+ return /*#__PURE__*/React__default.createElement(Box, Object.assign({
4232
+ role: "tabpanel",
4233
+ hidden: value !== index,
4234
+ id: "simple-tabpanel-".concat(index),
4235
+ "aria-labelledby": "simple-tab-".concat(index),
4236
+ "data-testid": "tab-panel-".concat(index)
4237
+ }, other), value === index && children);
4366
4238
  };
4367
4239
 
4368
- var getDraftTitle = function getDraftTitle(status) {
4369
- if (status === 'DRAFT_AMENDED') {
4370
- return 'Draft amendment';
4371
- }
4372
-
4373
- if (status === 'DRAFT_CORRECTED') {
4374
- return 'Draft correction';
4375
- }
4240
+ /* *
4241
+ * Licensed under the Apache License, Version 2.0 (the "License");
4242
+ * you may not use this file except in compliance with the License.
4243
+ * You may obtain a copy of the License at
4244
+ *
4245
+ * http://www.apache.org/licenses/LICENSE-2.0
4246
+ *
4247
+ * Unless required by applicable law or agreed to in writing, software
4248
+ * distributed under the License is distributed on an "AS IS" BASIS,
4249
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4250
+ * See the License for the specific language governing permissions and
4251
+ * limitations under the License.
4252
+ *
4253
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4254
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4255
+ * */
4376
4256
 
4377
- return 'Draft';
4257
+ var TafHeader = function TafHeader(_ref) {
4258
+ var title = _ref.title;
4259
+ return /*#__PURE__*/React__default.createElement(Typography, {
4260
+ sx: {
4261
+ textAlign: 'center',
4262
+ fontWeight: 500,
4263
+ paddingTop: '6px',
4264
+ textTransform: 'capitalize'
4265
+ }
4266
+ }, title);
4378
4267
  };
4379
- var useStyles$4 = makeStyles({
4380
- cardWrapper: {
4381
- width: '100%'
4382
- },
4383
- cardContent: {
4384
- width: '100%'
4385
- },
4386
- activeStatus: {
4387
- color: '#72bb23'
4388
- },
4389
- font: {
4390
- fontWeight: 'normal'
4391
- },
4392
- alignIcon: {
4393
- display: 'flex',
4394
- alignSelf: 'center'
4395
- }
4396
- });
4397
4268
 
4398
- var TafListRow = function TafListRow(_ref) {
4399
- var taf = _ref.taf,
4400
- listType = _ref.listType,
4401
- _ref$TAC = _ref.TAC,
4402
- TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
4403
- _ref$showTac = _ref.showTac,
4404
- showTac = _ref$showTac === void 0 ? false : _ref$showTac;
4405
- var classes = useStyles$4();
4406
- var validTimeDate = moment.utc(taf.validDateStart).format('DD MMM');
4407
- var baseTime = moment.utc(taf.baseTime).format('HH:mm');
4408
- return /*#__PURE__*/React__default.createElement(Card, {
4409
- elevation: 0,
4410
- className: classes.cardWrapper
4411
- }, /*#__PURE__*/React__default.createElement(Grid, {
4412
- container: true,
4413
- alignItems: "center",
4414
- spacing: 1
4415
- }, /*#__PURE__*/React__default.createElement(Grid, {
4416
- item: true,
4417
- xs: 3,
4418
- sm: 2,
4419
- md: 1
4420
- }, /*#__PURE__*/React__default.createElement(Typography, {
4421
- variant: "subtitle2",
4422
- noWrap: true,
4423
- className: classes.font
4424
- }, taf.location)), /*#__PURE__*/React__default.createElement(Grid, {
4425
- item: true,
4426
- xs: 3,
4427
- sm: 3,
4428
- md: 1,
4429
- container: true
4430
- }, /*#__PURE__*/React__default.createElement(Grid, {
4431
- item: true,
4432
- xs: 3,
4433
- sm: 3,
4434
- md: 3,
4435
- className: classes.alignIcon
4436
- }, showTac && /*#__PURE__*/React__default.createElement(Tooltip, {
4437
- "data-testid": "taflistrow-tactooltip",
4438
- title: /*#__PURE__*/React__default.createElement("div", {
4439
- style: {
4440
- whiteSpace: 'pre-line'
4441
- }
4442
- }, TAC),
4443
- placement: "bottom-start"
4444
- }, /*#__PURE__*/React__default.createElement(InfoOutlined, {
4445
- "data-testid": "taflistrow-tacicon",
4446
- color: "secondary",
4447
- fontSize: "small"
4448
- }))), /*#__PURE__*/React__default.createElement(Grid, {
4449
- item: true,
4450
- xs: 9,
4451
- sm: 9,
4452
- md: 9
4453
- }, /*#__PURE__*/React__default.createElement(Typography, {
4454
- variant: "subtitle2",
4455
- className: classes.font,
4456
- "data-testid": "baseTime"
4457
- }, baseTime))), /*#__PURE__*/React__default.createElement(Grid, {
4458
- item: true,
4459
- xs: 3,
4460
- sm: 2,
4461
- md: 1
4462
- }, /*#__PURE__*/React__default.createElement(Typography, {
4463
- variant: "subtitle2",
4464
- className: classes.font,
4465
- "data-testid": "validTimeDate"
4466
- }, validTimeDate)), /*#__PURE__*/React__default.createElement(Grid, {
4467
- item: true,
4468
- xs: 3,
4469
- sm: 3,
4470
- md: 6
4471
- }, /*#__PURE__*/React__default.createElement(Typography, {
4472
- variant: "subtitle2",
4473
- className: classes.font,
4474
- "data-testid": "validTimeSlot"
4475
- }, formatValidToString({
4476
- start: taf.validDateStart,
4477
- end: taf.validDateEnd
4478
- }))), /*#__PURE__*/React__default.createElement(Grid, {
4479
- item: true,
4480
- xs: 12,
4481
- sm: 4,
4482
- md: 3
4483
- }, /*#__PURE__*/React__default.createElement(Grid, {
4484
- container: true,
4485
- justifyContent: "flex-start",
4486
- spacing: 2
4487
- }, /*#__PURE__*/React__default.createElement(Grid, {
4488
- item: true,
4489
- xs: 8,
4490
- container: true,
4491
- justifyContent: "flex-end"
4492
- }, taf.status === 'DRAFT' || taf.status === 'DRAFT_CORRECTED' || taf.status === 'DRAFT_AMENDED' ? /*#__PURE__*/React__default.createElement(Button, {
4493
- color: "secondary",
4494
- size: "small",
4495
- "data-testid": "tafRow-draft",
4496
- startIcon: /*#__PURE__*/React__default.createElement(Create, {
4497
- fontSize: "small",
4498
- color: "secondary"
4499
- })
4500
- }, getDraftTitle(taf.status)) : getStatusTagList(taf)), /*#__PURE__*/React__default.createElement(Grid, {
4501
- item: true,
4502
- className: classes.alignIcon
4503
- }, taf.status !== 'NEW' && taf.status !== 'DRAFT' && taf.status !== 'DRAFT_CORRECTED' && taf.status !== 'DRAFT_AMENDED' && taf.status !== 'CANCELLED' && listType !== 'EXPIRED' && getActiveStatus(listType, classes.activeStatus))))));
4269
+ var location_indicator_mwo = "EHDB";
4270
+ var locations = {
4271
+ EHAM: {
4272
+ validity_duration: 30,
4273
+ activity_period: 6,
4274
+ label: "Schiphol"
4275
+ },
4276
+ EHRD: {
4277
+ validity_duration: 30,
4278
+ activity_period: 6,
4279
+ label: "Rotterdam"
4280
+ },
4281
+ EHGG: {
4282
+ validity_duration: 30,
4283
+ activity_period: 6,
4284
+ label: "Eelde"
4285
+ },
4286
+ EHBK: {
4287
+ validity_duration: 30,
4288
+ activity_period: 6,
4289
+ label: "Maastricht"
4290
+ },
4291
+ EHLE: {
4292
+ validity_duration: 30,
4293
+ activity_period: 6,
4294
+ label: "Lelystad"
4295
+ },
4296
+ TNCB: {
4297
+ validity_duration: 30,
4298
+ activity_period: 6,
4299
+ label: "Bonaire"
4300
+ }
4301
+ };
4302
+ var locationOrder = [
4303
+ "EHAM",
4304
+ "EHRD",
4305
+ "EHLE",
4306
+ "EHGG",
4307
+ "EHBK",
4308
+ "TNCB"
4309
+ ];
4310
+ var tafConfig = {
4311
+ location_indicator_mwo: location_indicator_mwo,
4312
+ locations: locations,
4313
+ locationOrder: locationOrder
4504
4314
  };
4505
4315
 
4506
- /* *
4507
- * Licensed under the Apache License, Version 2.0 (the "License");
4508
- * you may not use this file except in compliance with the License.
4509
- * You may obtain a copy of the License at
4510
- *
4511
- * http://www.apache.org/licenses/LICENSE-2.0
4512
- *
4513
- * Unless required by applicable law or agreed to in writing, software
4514
- * distributed under the License is distributed on an "AS IS" BASIS,
4515
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4516
- * See the License for the specific language governing permissions and
4517
- * limitations under the License.
4518
- *
4519
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4520
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4521
- * */
4522
- var getListType = function getListType(taf, locationSettings) {
4523
- if (!taf) return null;
4316
+ var getTafSettings = function getTafSettings() {
4317
+ return tafConfig;
4318
+ };
4319
+
4320
+ var tafSettings = getTafSettings();
4321
+ var getLocationSetting = function getLocationSetting(location) {
4322
+ var locationSettings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : tafSettings.locations;
4323
+ return locationSettings[location];
4324
+ };
4325
+ var sortTafsOnLocation = function sortTafsOnLocation(tafList) {
4326
+ var locationOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : tafSettings.locationOrder;
4327
+ if (!tafList) return [];
4328
+ return _toConsumableArray(tafList).sort(function (_ref, _ref2) {
4329
+ var tafA = _ref.taf;
4330
+ var tafB = _ref2.taf;
4331
+ return locationOrder.indexOf(tafA.location) < locationOrder.indexOf(tafB.location) ? -1 : 1;
4332
+ });
4333
+ };
4334
+ var getBaseTime = function getBaseTime(baseTime, location) {
4335
+ var currentBaseTime = moment.utc(baseTime);
4336
+ var activityPeriod = getLocationSetting(location).activity_period;
4337
+ var nextBaseTime = moment.utc(baseTime).add(activityPeriod, 'hours');
4338
+ return {
4339
+ currentBaseTime: currentBaseTime,
4340
+ nextBaseTime: nextBaseTime
4341
+ };
4342
+ };
4343
+ var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status) {
4524
4344
  var now = moment.utc();
4525
- var baseTime = moment.utc(taf.baseTime);
4526
- var activityPeriod = locationSettings[taf.location].activity_period;
4527
- var nextBaseTime = moment.utc(taf.baseTime).add(activityPeriod, 'hours');
4528
4345
 
4529
- if (taf.status === 'EXPIRED') {
4346
+ var _getBaseTime = getBaseTime(baseTime, location),
4347
+ currentBaseTime = _getBaseTime.currentBaseTime,
4348
+ nextBaseTime = _getBaseTime.nextBaseTime;
4349
+
4350
+ if (status === 'EXPIRED') {
4530
4351
  return 'EXPIRED';
4531
4352
  }
4532
4353
 
4533
- if (baseTime < now && nextBaseTime > now) {
4354
+ if (currentBaseTime < now && nextBaseTime > now) {
4534
4355
  return 'ACTIVE';
4535
4356
  }
4536
4357
 
4537
4358
  return 'UPCOMING';
4538
4359
  };
4360
+ var sortTafTimeSlots = function sortTafTimeSlots(tafList) {
4361
+ var sortedListOnLocation = sortTafsOnLocation(tafList);
4362
+ return sortedListOnLocation.reduce(function (sortedTafList, tafFromBackend) {
4363
+ var taf = tafFromBackend.taf;
4364
+ var timeSlot = getTafTimeSlot(taf.baseTime, taf.location, taf.status);
4365
+
4366
+ if (timeSlot === 'EXPIRED') {
4367
+ sortedTafList.expired.push(tafFromBackend);
4368
+ } else if (timeSlot === 'ACTIVE') {
4369
+ sortedTafList.current.push(tafFromBackend);
4370
+ } else {
4371
+ sortedTafList.upcoming.push(tafFromBackend);
4372
+ }
4373
+
4374
+ return sortedTafList;
4375
+ }, {
4376
+ current: [],
4377
+ upcoming: [],
4378
+ expired: []
4379
+ });
4380
+ };
4381
+ var muiTabA11yProps = function muiTabA11yProps(index) {
4382
+ return {
4383
+ id: "simple-tab-".concat(index),
4384
+ 'aria-controls': "simple-tabpanel-".concat(index)
4385
+ };
4386
+ };
4539
4387
 
4540
4388
  /* *
4541
4389
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4550,143 +4398,334 @@ var getListType = function getListType(taf, locationSettings) {
4550
4398
  * See the License for the specific language governing permissions and
4551
4399
  * limitations under the License.
4552
4400
  *
4553
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4554
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4401
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4402
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4555
4403
  * */
4556
4404
 
4557
- var TafFormDialog = function TafFormDialog(_ref) {
4558
- var open = _ref.open,
4559
- toggleFormDialog = _ref.toggleFormDialog,
4560
- tafFromBackend = _ref.tafFromBackend,
4561
- children = _ref.children,
4562
- _ref$alertBanner = _ref.alertBanner,
4563
- alertBanner = _ref$alertBanner === void 0 ? null : _ref$alertBanner,
4564
- onFormAction = _ref.onFormAction;
4565
- var taf = tafFromBackend ? tafFromBackend.taf : null;
4566
-
4567
- var _useTafSettings = useTafSettings(tafConfig),
4568
- locationSettings = _useTafSettings.locations;
4569
-
4570
- return /*#__PURE__*/React__default.createElement(ContentDialog, {
4571
- open: open,
4572
- toggleDialogStatus: toggleFormDialog,
4573
- titleComponent: /*#__PURE__*/React__default.createElement(TafListRow, {
4574
- taf: taf,
4575
- listType: getListType(taf, locationSettings)
4576
- }),
4577
- alertBanner: alertBanner,
4578
- onFormAction: onFormAction
4579
- }, children);
4405
+ var EditIcon = function EditIcon(props) {
4406
+ var theme = useTheme();
4407
+ return /*#__PURE__*/React.createElement(SvgIcon, Object.assign({}, props), /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", {
4408
+ d: "m8.332 17.09-.005.001-2.652.604.956-2.542.001-.001.001-.001.857-.744 1.69 1.945-.848.738zm.71.815L20.932 7.577 17.823 4 5.933 14.329l-.01.008.005.005L4.173 19l4.857-1.09-.004-.02.019.02-.002-.005z",
4409
+ fillRule: "evenodd",
4410
+ fill: "".concat(theme.palette.geowebColors.buttons.tertiary["default"].color)
4411
+ })));
4580
4412
  };
4581
4413
 
4582
- var useStyles$3 = makeStyles({
4583
- accordion: {
4584
- marginBottom: '5px'
4585
- },
4586
- formPadding: {
4587
- padding: '8px'
4588
- },
4589
- expandIcon: {
4590
- color: '#0075a9'
4591
- }
4592
- });
4414
+ var StatusIcon = function StatusIcon(_ref) {
4415
+ var timeSlot = _ref.timeSlot,
4416
+ status = _ref.status;
4593
4417
 
4594
- var fromStatusToAction = function fromStatusToAction(tafStatus) {
4595
- switch (tafStatus) {
4596
- case 'DRAFT':
4597
- return 'DRAFT';
4418
+ if (status === 'NEW') {
4419
+ return null;
4420
+ }
4598
4421
 
4599
- case 'DRAFT_AMENDED':
4600
- return 'DRAFT_AMEND';
4422
+ if (status === 'EXPIRED') {
4423
+ return /*#__PURE__*/React.createElement(Schedule, {
4424
+ "data-testid": "status-expired",
4425
+ fontSize: "small",
4426
+ sx: {
4427
+ transform: 'scaleX(-1)',
4428
+ color: 'geowebColors.buttons.tertiary.disabled.color'
4429
+ }
4430
+ });
4431
+ }
4601
4432
 
4602
- case 'DRAFT_CORRECTED':
4603
- return 'DRAFT_CORRECT';
4433
+ if (status === 'CANCELLED') {
4434
+ return /*#__PURE__*/React.createElement(DoDisturbIcon, {
4435
+ "data-testid": "status-cancelled",
4436
+ fontSize: "small",
4437
+ sx: {
4438
+ color: 'geowebColors.captions.captionError.rgba'
4439
+ }
4440
+ });
4441
+ }
4604
4442
 
4605
- default:
4606
- return 'NEW';
4443
+ if (status === 'DRAFT' || status === 'DRAFT_CORRECTED' || status === 'DRAFT_AMENDED') {
4444
+ return /*#__PURE__*/React.createElement(EditIcon, {
4445
+ "data-testid": "status-draft"
4446
+ });
4607
4447
  }
4448
+
4449
+ return timeSlot === 'ACTIVE' ? /*#__PURE__*/React.createElement(CheckCircle, {
4450
+ "data-testid": "status-active",
4451
+ fontSize: "small",
4452
+ sx: {
4453
+ color: 'geowebColors.functional.success'
4454
+ }
4455
+ }) : /*#__PURE__*/React.createElement(Schedule, {
4456
+ "data-testid": "status-upcoming",
4457
+ fontSize: "small",
4458
+ sx: {
4459
+ color: 'geowebColors.functional.success'
4460
+ }
4461
+ });
4608
4462
  };
4609
4463
 
4610
- var TafListAccordion = function TafListAccordion(_ref) {
4611
- var tafListItem = _ref.tafListItem,
4612
- listType = _ref.listType,
4613
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4614
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4615
- onClickTafActionButton = _ref.onClickTafActionButton;
4616
- var classes = useStyles$3();
4617
- var status = tafListItem.taf.status;
4464
+ var TacContainer = function TacContainer(_ref) {
4465
+ var taf = _ref.taf,
4466
+ _ref$isActive = _ref.isActive,
4467
+ isActive = _ref$isActive === void 0 ? false : _ref$isActive;
4618
4468
 
4619
4469
  var _useApiContext = useApiContext(),
4620
4470
  api = _useApiContext.api;
4621
4471
 
4622
- var _useTACGenerator = useTACGenerator(tafListItem.taf, api.getTAC),
4472
+ var _useTACGenerator = useTACGenerator(taf, api.getTAC),
4623
4473
  _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
4624
4474
  TAC = _useTACGenerator2[0],
4625
- requestTAC = _useTACGenerator2[1];
4475
+ retrieveTAC = _useTACGenerator2[1];
4626
4476
 
4477
+ var status = taf.status,
4478
+ location = taf.location,
4479
+ baseTime = taf.baseTime;
4480
+ var locationLabel = getLocationSetting(location).label;
4481
+ var timeSlot = getTafTimeSlot(baseTime, location, status);
4627
4482
  React__default.useEffect(function () {
4628
- // only re-retrieve TAC if draft state
4629
- if (tafListItem.taf.status === 'DRAFT' || tafListItem.taf.status === 'DRAFT_AMENDED' || tafListItem.taf.status === 'DRAFT_CORRECTED') {
4630
- requestTAC(tafListItem.taf);
4631
- } // eslint-disable-next-line react-hooks/exhaustive-deps
4483
+ if (isActive) {
4484
+ retrieveTAC(taf);
4485
+ }
4486
+ }, [taf, isActive, retrieveTAC]);
4487
+ return /*#__PURE__*/React__default.createElement(Box, {
4488
+ sx: {
4489
+ marginBottom: '20px'
4490
+ },
4491
+ "data-location": location,
4492
+ className: isActive ? 'active' : null
4493
+ }, /*#__PURE__*/React__default.createElement(Box, {
4494
+ sx: {
4495
+ display: 'flex',
4496
+ alignItems: 'center',
4497
+ marginBottom: '2px'
4498
+ }
4499
+ }, /*#__PURE__*/React__default.createElement(Box, {
4500
+ sx: {
4501
+ width: 20,
4502
+ height: 20,
4503
+ display: 'flex',
4504
+ marginRight: '6px'
4505
+ }
4506
+ }, /*#__PURE__*/React__default.createElement(StatusIcon, {
4507
+ timeSlot: timeSlot,
4508
+ status: status
4509
+ })), /*#__PURE__*/React__default.createElement(Typography, {
4510
+ sx: Object.assign({
4511
+ lineHeight: 1
4512
+ }, isActive && {
4513
+ backgroundColor: 'geowebColors.functional.warningHighlight.rgba',
4514
+ padding: '0 2px',
4515
+ marginLeft: '-2px'
4516
+ })
4517
+ }, /*#__PURE__*/React__default.createElement(Typography, {
4518
+ sx: {
4519
+ fontSize: '12px',
4520
+ color: 'geowebColors.captions.captionInformation.rgba'
4521
+ },
4522
+ "data-testid": "tafLocation",
4523
+ component: "span"
4524
+ }, location), /*#__PURE__*/React__default.createElement(Typography, {
4525
+ sx: {
4526
+ fontSize: '12px',
4527
+ marginLeft: '10px'
4528
+ },
4529
+ "data-testid": "tafLocationLabel",
4530
+ component: "span"
4531
+ }, locationLabel))), /*#__PURE__*/React__default.createElement(Box, {
4532
+ sx: {
4533
+ fontSize: '12px',
4534
+ letterSpacing: '0.4px',
4535
+ color: 'geowebColors.captions.captionStatus.rgba'
4536
+ }
4537
+ }, TAC.split('\n').map(function (line) {
4538
+ return /*#__PURE__*/React__default.createElement(Box, {
4539
+ component: "span",
4540
+ key: line,
4541
+ sx: {
4542
+ display: 'inline-block'
4543
+ }
4544
+ }, /*#__PURE__*/React__default.createElement(Box, {
4545
+ component: "span",
4546
+ sx: Object.assign({
4547
+ display: 'inline',
4548
+ boxDecorationBreak: 'clone',
4549
+ WebkitBoxDecorationBreak: 'clone'
4550
+ }, isActive && {
4551
+ backgroundColor: 'geowebColors.functional.warningHighlight.rgba'
4552
+ })
4553
+ }, line));
4554
+ })));
4555
+ };
4556
+
4557
+ var TacOverview = function TacOverview(_ref) {
4558
+ var _ref$upcomingTafs = _ref.upcomingTafs,
4559
+ upcomingTafs = _ref$upcomingTafs === void 0 ? [] : _ref$upcomingTafs,
4560
+ _ref$currentTafs = _ref.currentTafs,
4561
+ currentTafs = _ref$currentTafs === void 0 ? [] : _ref$currentTafs,
4562
+ _ref$expiredTafs = _ref.expiredTafs,
4563
+ expiredTafs = _ref$expiredTafs === void 0 ? [] : _ref$expiredTafs,
4564
+ _ref$hideTitle = _ref.hideTitle,
4565
+ hideTitle = _ref$hideTitle === void 0 ? false : _ref$hideTitle,
4566
+ _ref$activeTaf = _ref.activeTaf,
4567
+ activeTaf = _ref$activeTaf === void 0 ? null : _ref$activeTaf;
4568
+
4569
+ var _React$useState = React__default.useState(0),
4570
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4571
+ activeTab = _React$useState2[0],
4572
+ setActiveTab = _React$useState2[1];
4573
+
4574
+ var scrollRef = React__default.useRef(null);
4575
+ var tabs = [{
4576
+ title: 'Upcoming',
4577
+ tafList: upcomingTafs
4578
+ }, {
4579
+ title: 'Current & Expired',
4580
+ tafList: sortTafsOnLocation([].concat(_toConsumableArray(currentTafs), _toConsumableArray(expiredTafs)))
4581
+ }];
4582
+ var activeLocation = (activeTaf === null || activeTaf === void 0 ? void 0 : activeTaf.taf.location) || null;
4583
+
4584
+ var isActiveLocation = function isActiveLocation(location) {
4585
+ return location === activeLocation;
4586
+ };
4587
+
4588
+ var scrollToPosition = React__default.useCallback(function () {
4589
+ if (!scrollRef.current) return;
4590
+ var containerTop = scrollRef.current.getBoundingClientRect().top;
4591
+ var firstLocation = scrollRef.current.querySelector("[data-location=\"".concat(activeLocation, "\"]"));
4592
+ var paddingTop = parseInt(getComputedStyle(scrollRef.current).paddingTop, 10);
4593
+ var newScrollPosition = (firstLocation === null || firstLocation === void 0 ? void 0 : firstLocation.getBoundingClientRect().top) - containerTop + scrollRef.current.scrollTop - paddingTop;
4594
+ scrollRef.current.scrollTo(newScrollPosition, newScrollPosition);
4595
+ }, [activeLocation]);
4596
+
4597
+ var resetScrollPosition = function resetScrollPosition() {
4598
+ return scrollRef.current.scrollTo(0, 0);
4599
+ };
4600
+
4601
+ var onChangeTab = function onChangeTab(_event, newValue) {
4602
+ setActiveTab(newValue);
4603
+ resetScrollPosition();
4604
+ };
4632
4605
 
4633
- }, [tafListItem.taf]);
4634
- var popOut = status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED';
4635
- return /*#__PURE__*/React__default.createElement(Accordion, Object.assign({
4636
- "data-testid": "tafListItem",
4637
- className: classes.accordion
4638
- }, popOut ? {
4639
- expanded: false
4640
- } : {}, {
4606
+ React__default.useEffect(function () {
4607
+ if (activeLocation) {
4608
+ scrollToPosition();
4609
+ }
4610
+ }, [activeLocation, scrollToPosition]);
4611
+ React__default.useEffect(function () {
4612
+ var SCROLL_DELAY = 1000;
4613
+ var timer = setTimeout(function () {
4614
+ scrollToPosition();
4615
+ }, SCROLL_DELAY);
4616
+ return function () {
4617
+ clearTimeout(timer);
4618
+ };
4619
+ }, [activeTab, scrollToPosition]);
4620
+ return /*#__PURE__*/React__default.createElement(Card, {
4621
+ variant: "outlined",
4622
+ sx: {
4623
+ maxHeight: '100%',
4624
+ overflow: 'hidden',
4625
+ display: 'flex',
4626
+ flexDirection: 'column'
4627
+ }
4628
+ }, /*#__PURE__*/React__default.createElement(Box, {
4629
+ sx: {
4630
+ zIndex: 1
4631
+ }
4632
+ }, !hideTitle && /*#__PURE__*/React__default.createElement(TafHeader, {
4633
+ title: "TAC Overview"
4634
+ }), /*#__PURE__*/React__default.createElement(Tabs, {
4635
+ value: activeTab,
4636
+ onChange: onChangeTab,
4637
+ "aria-label": "tabs"
4638
+ }, tabs.map(function (tab, index) {
4639
+ return /*#__PURE__*/React__default.createElement(Tab, Object.assign({
4640
+ key: tab.title,
4641
+ sx: {
4642
+ flexGrow: 1
4643
+ },
4644
+ label: tab.title,
4645
+ "data-testid": "tab-".concat(index)
4646
+ }, muiTabA11yProps(index)));
4647
+ }))), /*#__PURE__*/React__default.createElement(Box, {
4648
+ ref: scrollRef,
4649
+ sx: {
4650
+ padding: '10px',
4651
+ maxHeight: '100%',
4652
+ overflow: 'auto'
4653
+ }
4654
+ }, tabs.map(function (tab, index) {
4655
+ return /*#__PURE__*/React__default.createElement(TabPanel, {
4656
+ key: tab.title,
4657
+ value: activeTab,
4658
+ index: index
4659
+ }, tab.tafList.map(function (_ref2) {
4660
+ var taf = _ref2.taf;
4661
+ return /*#__PURE__*/React__default.createElement(TacContainer, {
4662
+ key: taf.uuid,
4663
+ taf: taf,
4664
+ isActive: isActiveLocation(taf.location)
4665
+ });
4666
+ }));
4667
+ })));
4668
+ };
4669
+
4670
+ var TacOverviewIcon = /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
4671
+ d: "M3 3h4v4H3V3zm0 7h4v4H3v-4zm0 7h4v4H3v-4zm7-14h11v4H10V3zm0 7h11v4H10v-4zm0 7h11v4H10v-4z"
4672
+ }));
4673
+
4674
+ var TacOverviewMobile = function TacOverviewMobile(_ref) {
4675
+ var upcomingTafs = _ref.upcomingTafs,
4676
+ currentTafs = _ref.currentTafs,
4677
+ expiredTafs = _ref.expiredTafs,
4678
+ activeTaf = _ref.activeTaf,
4679
+ _ref$defaultOpen = _ref.defaultOpen,
4680
+ defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen;
4681
+
4682
+ var _React$useState = React.useState(defaultOpen),
4683
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4684
+ isOpen = _React$useState2[0],
4685
+ toggleOpen = _React$useState2[1];
4686
+
4687
+ var onClose = function onClose() {
4688
+ return toggleOpen(false);
4689
+ };
4690
+
4691
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolButton, {
4692
+ active: isOpen,
4641
4693
  onClick: function onClick() {
4642
- if (popOut) {
4643
- onClickTafActionButton(fromStatusToAction(tafListItem.taf.status), tafListItem.taf.uuid);
4644
- }
4694
+ return toggleOpen(true);
4645
4695
  },
4646
- TransitionProps: {
4647
- unmountOnExit: true
4696
+ "data-testid": "tac-overview-mobile-button",
4697
+ sx: {
4698
+ display: {
4699
+ xs: 'inline-flex',
4700
+ sm: 'none'
4701
+ },
4702
+ position: 'absolute',
4703
+ right: '8px',
4704
+ top: '30px'
4648
4705
  }
4649
- }), /*#__PURE__*/React__default.createElement(AccordionSummary, {
4650
- "data-testid": "tafListSectionAccordionSummary",
4651
- expandIcon: popOut ? /*#__PURE__*/React__default.createElement(Tooltip, {
4652
- title: "Popout to edit",
4653
- className: classes.expandIcon
4654
- }, /*#__PURE__*/React__default.createElement(OpenInNew, {
4655
- "data-testid": "popOutIcon",
4656
- fontSize: "small"
4657
- })) : /*#__PURE__*/React__default.createElement(ExpandMore, {
4658
- className: classes.expandIcon,
4659
- "data-testid": "expandIcon"
4660
- })
4661
- }, /*#__PURE__*/React__default.createElement(TafListRow, {
4662
- taf: tafListItem.taf,
4663
- listType: listType,
4664
- TAC: TAC,
4665
- showTac: true
4666
- })), /*#__PURE__*/React__default.createElement(AccordionDetails, null, /*#__PURE__*/React__default.createElement(Grid, {
4667
- container: true,
4668
- direction: "column"
4669
- }, errorCancelTaf.length > 0 && errorCancelTaf.find(function (uuid) {
4670
- return uuid === tafListItem.taf.uuid;
4671
- }) && /*#__PURE__*/React__default.createElement(AlertBanner, {
4672
- severity: "error",
4673
- title: "Cancelling this TAF failed, please try again",
4674
- dataTestId: "tafList-cancelAlert"
4675
- }), /*#__PURE__*/React__default.createElement("div", {
4676
- className: classes.formPadding
4677
- }, /*#__PURE__*/React__default.createElement(Grid, {
4678
- item: true
4679
- }, /*#__PURE__*/React__default.createElement(TafFormWrapper, {
4680
- tafFromBackend: tafListItem,
4681
- mode: "view",
4682
- TAC: TAC
4683
- })), /*#__PURE__*/React__default.createElement(Grid, {
4684
- item: true
4685
- }, /*#__PURE__*/React__default.createElement(TafListButtons, {
4686
- canBe: tafListItem.canbe,
4687
- uuid: tafListItem.taf.uuid,
4688
- onClickTafActionButton: onClickTafActionButton
4689
- }))))));
4706
+ }, TacOverviewIcon), /*#__PURE__*/React.createElement(Dialog, {
4707
+ open: isOpen,
4708
+ onClose: onClose,
4709
+ PaperProps: {
4710
+ sx: {
4711
+ margin: 2,
4712
+ width: '100%',
4713
+ height: '100%'
4714
+ }
4715
+ },
4716
+ "data-testid": "tac-overview-mobile"
4717
+ }, /*#__PURE__*/React.createElement(ToolHeader, {
4718
+ title: "TAC Overview",
4719
+ size: "small",
4720
+ isDraggable: false,
4721
+ onClose: onClose
4722
+ }), /*#__PURE__*/React.createElement(TacOverview, {
4723
+ upcomingTafs: upcomingTafs,
4724
+ currentTafs: currentTafs,
4725
+ expiredTafs: expiredTafs,
4726
+ activeTaf: activeTaf,
4727
+ hideTitle: true
4728
+ })));
4690
4729
  };
4691
4730
 
4692
4731
  /* *
@@ -4702,136 +4741,131 @@ var TafListAccordion = function TafListAccordion(_ref) {
4702
4741
  * See the License for the specific language governing permissions and
4703
4742
  * limitations under the License.
4704
4743
  *
4705
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4706
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4744
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4745
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4707
4746
  * */
4708
- var useStyles$2 = makeStyles({
4709
- listHeaders: {
4710
- color: '#9d9d9d'
4711
- },
4712
- formPadding: {
4713
- padding: '8px'
4714
- },
4715
- paperButton: {
4716
- width: '100%'
4717
- }
4718
- });
4719
-
4720
- var TafListSection = function TafListSection(_ref) {
4721
- var tafList = _ref.tafList,
4722
- title = _ref.title,
4723
- listType = _ref.listType,
4724
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4725
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4726
- onClickTafActionButton = _ref.onClickTafActionButton;
4727
- var classes = useStyles$2();
4728
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Typography, {
4729
- variant: "subtitle2",
4730
- className: classes.listHeaders
4731
- }, title), /*#__PURE__*/React__default.createElement("div", {
4732
- "data-testid": "tafList".concat(listType)
4733
- }, tafList.map(function (tafListItem) {
4734
- return /*#__PURE__*/React__default.createElement(TafListAccordion, {
4735
- key: "".concat(tafListItem.taf.uuid, "-").concat(tafListItem.taf.status),
4736
- tafListItem: tafListItem,
4737
- listType: listType,
4738
- errorCancelTaf: errorCancelTaf,
4739
- onClickTafActionButton: onClickTafActionButton
4740
- });
4741
- })));
4747
+ var formatBaseTime = function formatBaseTime(time) {
4748
+ return time.format('HH:mm DD MMM');
4742
4749
  };
4743
4750
 
4744
- var useStyles$1 = makeStyles({
4745
- accordion: {
4746
- marginBottom: '5px'
4747
- },
4748
- listHeaders: {
4749
- color: '#9d9d9d'
4750
- },
4751
- listBody: {
4752
- width: '100%',
4753
- minHeight: '600px'
4751
+ var TopTabs = function TopTabs(_ref) {
4752
+ var timeSlot = _ref.timeSlot,
4753
+ _ref$onChangeTimeSlot = _ref.onChangeTimeSlot,
4754
+ onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot,
4755
+ tafFromBackend = _ref.tafFromBackend;
4756
+
4757
+ if (!tafFromBackend) {
4758
+ return null;
4754
4759
  }
4755
- });
4756
4760
 
4757
- var TafList = function TafList(_ref) {
4758
- var tafList = _ref.tafList,
4759
- isLoading = _ref.isLoading,
4760
- error = _ref.error,
4761
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4762
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4763
- onClickTafActionButton = _ref.onClickTafActionButton;
4764
- var classes = useStyles$1();
4761
+ var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
4765
4762
 
4766
- var _useTafSettings = useTafSettings(tafConfig),
4767
- locationSettings = _useTafSettings.locations;
4763
+ var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
4764
+ currentBaseTime = _getBaseTime.currentBaseTime,
4765
+ nextBaseTime = _getBaseTime.nextBaseTime;
4768
4766
 
4769
- var upcomingTafs = [];
4770
- var currentTafs = [];
4771
- var expiredTafs = [];
4767
+ var tabs = [{
4768
+ title: "Upcoming ".concat(formatBaseTime(nextBaseTime)),
4769
+ timeSlot: 'UPCOMING'
4770
+ }, {
4771
+ title: "Current ".concat(formatBaseTime(currentBaseTime)),
4772
+ timeSlot: 'ACTIVE'
4773
+ }];
4772
4774
 
4773
- if (tafList) {
4774
- var _iterator = _createForOfIteratorHelper(tafList),
4775
- _step;
4775
+ var onChangeTab = function onChangeTab(_event, newValue) {
4776
+ onChangeTimeSlot(tabs[newValue].timeSlot);
4777
+ };
4776
4778
 
4777
- try {
4778
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
4779
- var taf = _step.value;
4780
- var now = moment.utc();
4781
- var baseTime = moment.utc(taf.taf.baseTime);
4782
- var activityPeriod = locationSettings[taf.taf.location].activity_period;
4783
- var nextBaseTime = moment.utc(taf.taf.baseTime).add(activityPeriod, 'hours');
4784
-
4785
- if (taf.taf.status === 'EXPIRED') {
4786
- expiredTafs.push(taf);
4787
- } else if (baseTime < now && nextBaseTime > now) {
4788
- currentTafs.push(taf);
4789
- } else {
4790
- upcomingTafs.push(taf);
4791
- }
4779
+ return /*#__PURE__*/React__default.createElement(Tabs, {
4780
+ value: activeTab,
4781
+ onChange: onChangeTab,
4782
+ "aria-label": "timeslot-tabs",
4783
+ variant: "fullWidth"
4784
+ }, tabs.map(function (tab, index) {
4785
+ return /*#__PURE__*/React__default.createElement(Tab, Object.assign({
4786
+ key: tab.title,
4787
+ label: tab.title,
4788
+ "data-testid": "tab-".concat(index),
4789
+ sx: {
4790
+ fontSize: 16
4792
4791
  }
4793
- } catch (err) {
4794
- _iterator.e(err);
4795
- } finally {
4796
- _iterator.f();
4797
- }
4798
- }
4792
+ }, muiTabA11yProps(index)));
4793
+ }));
4794
+ };
4799
4795
 
4800
- return /*#__PURE__*/React__default.createElement(Grid, {
4801
- container: true,
4802
- direction: "column",
4803
- alignItems: "stretch"
4804
- }, /*#__PURE__*/React__default.createElement(Grid, {
4805
- item: true,
4806
- className: classes.listBody
4807
- }, error && /*#__PURE__*/React__default.createElement(AlertBanner, {
4808
- severity: "error",
4809
- title: "An error has occurred while retrieving the list, please try again",
4810
- info: error.message ? error.message : '',
4811
- dataTestId: "tafList-alert"
4812
- }), tafList && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafListSection, {
4813
- title: "Upcoming",
4814
- listType: "UPCOMING",
4815
- tafList: upcomingTafs,
4816
- errorCancelTaf: errorCancelTaf,
4817
- onClickTafActionButton: onClickTafActionButton
4818
- }), /*#__PURE__*/React__default.createElement(TafListSection, {
4819
- title: "Current time slot",
4820
- listType: "ACTIVE",
4821
- tafList: currentTafs,
4822
- errorCancelTaf: errorCancelTaf,
4823
- onClickTafActionButton: onClickTafActionButton
4824
- }), /*#__PURE__*/React__default.createElement(TafListSection, {
4825
- title: "Expired",
4826
- listType: "EXPIRED",
4827
- tafList: expiredTafs,
4828
- errorCancelTaf: errorCancelTaf,
4829
- onClickTafActionButton: onClickTafActionButton
4830
- })), isLoading && /*#__PURE__*/React__default.createElement(Skeleton, {
4831
- "data-testid": "tafList-skeleton",
4832
- variant: "rectangular",
4833
- height: "660px"
4834
- })));
4796
+ /* *
4797
+ * Licensed under the Apache License, Version 2.0 (the "License");
4798
+ * you may not use this file except in compliance with the License.
4799
+ * You may obtain a copy of the License at
4800
+ *
4801
+ * http://www.apache.org/licenses/LICENSE-2.0
4802
+ *
4803
+ * Unless required by applicable law or agreed to in writing, software
4804
+ * distributed under the License is distributed on an "AS IS" BASIS,
4805
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4806
+ * See the License for the specific language governing permissions and
4807
+ * limitations under the License.
4808
+ *
4809
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4810
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4811
+ * */
4812
+
4813
+ var LocationTabs = function LocationTabs(_ref) {
4814
+ var tafList = _ref.tafList,
4815
+ _ref$activeIndex = _ref.activeIndex,
4816
+ activeIndex = _ref$activeIndex === void 0 ? 0 : _ref$activeIndex,
4817
+ _ref$onChangeTab = _ref.onChangeTab,
4818
+ onChangeTab = _ref$onChangeTab === void 0 ? function () {} : _ref$onChangeTab,
4819
+ timeSlot = _ref.timeSlot;
4820
+ return /*#__PURE__*/React.createElement(MenuList, {
4821
+ "data-testid": "location-tabs",
4822
+ sx: {
4823
+ paddingTop: '32px'
4824
+ }
4825
+ }, tafList.map(function (_ref2, index) {
4826
+ var taf = _ref2.taf;
4827
+ return /*#__PURE__*/React.createElement(MenuItem, {
4828
+ key: taf.uuid,
4829
+ selected: index === activeIndex,
4830
+ sx: {
4831
+ backgroundColor: 'geowebColors.cards.cardContainer',
4832
+ borderColor: 'geowebColors.cards.cardContainerBorder',
4833
+ borderWidth: '1px',
4834
+ borderStyle: 'solid',
4835
+ margin: '0 0 4px',
4836
+ height: '56px',
4837
+ justifyContent: 'center',
4838
+ ':after': {
4839
+ background: 'none!important'
4840
+ },
4841
+ '&.Mui-selected': {
4842
+ backgroundColor: 'geowebColors.cards.cardContainer',
4843
+ marginRight: '-17px',
4844
+ borderRight: '0px',
4845
+ zIndex: 1
4846
+ }
4847
+ },
4848
+ onClick: function onClick() {
4849
+ return onChangeTab(index);
4850
+ }
4851
+ }, /*#__PURE__*/React.createElement(Box$1, {
4852
+ component: "span",
4853
+ sx: {
4854
+ fontSize: '12px',
4855
+ fontWeight: '500',
4856
+ letterSpacing: '0.09px',
4857
+ '& + svg': {
4858
+ position: 'absolute',
4859
+ bottom: '1px',
4860
+ width: '20px',
4861
+ height: '20px'
4862
+ }
4863
+ }
4864
+ }, taf.location), /*#__PURE__*/React.createElement(StatusIcon, {
4865
+ timeSlot: timeSlot,
4866
+ status: taf.status
4867
+ }));
4868
+ }));
4835
4869
  };
4836
4870
 
4837
4871
  /* *
@@ -4850,285 +4884,434 @@ var TafList = function TafList(_ref) {
4850
4884
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4851
4885
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
4852
4886
  * */
4853
- var useStyles = makeStyles({
4854
- backdrop: {
4855
- zIndex: 1500,
4856
- color: '#fff'
4857
- }
4858
- });
4859
4887
 
4860
- var Spinner = function Spinner() {
4861
- var classes = useStyles();
4862
- return /*#__PURE__*/React__default.createElement(Backdrop, {
4863
- open: true,
4864
- className: classes.backdrop
4865
- }, /*#__PURE__*/React__default.createElement(CircularProgress, {
4888
+ var Spinner = function Spinner(props) {
4889
+ return /*#__PURE__*/React__default.createElement(Backdrop, Object.assign({
4890
+ open: true
4891
+ }, props), /*#__PURE__*/React__default.createElement(CircularProgress, {
4866
4892
  "data-testid": "spinner",
4867
4893
  color: "inherit"
4868
4894
  }));
4869
4895
  };
4870
4896
 
4871
- var useTimeoutCancelError = function useTimeoutCancelError() {
4872
- var pollingInterval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10000;
4873
-
4874
- var _React$useState = React__default.useState([]),
4875
- _React$useState2 = _slicedToArray(_React$useState, 2),
4876
- errorCancelTaf = _React$useState2[0],
4877
- setErrorCancelTaf = _React$useState2[1];
4878
-
4879
- React__default.useEffect(function () {
4880
- var cancelErrorMessageHandler = errorCancelTaf.length > 0 ? setTimeout(function () {
4881
- if (errorCancelTaf.length > 0) {
4882
- setErrorCancelTaf(errorCancelTaf.slice(1));
4883
- }
4884
- }, pollingInterval) : null;
4885
- return function () {
4886
- if (cancelErrorMessageHandler !== null) {
4887
- clearTimeout(cancelErrorMessageHandler);
4888
- }
4889
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
4890
- }, [errorCancelTaf]);
4891
- return [errorCancelTaf, setErrorCancelTaf];
4892
- };
4893
- var getSelectedTaf = function getSelectedTaf(selectedTafId, tafList) {
4894
- if (tafList === null) return undefined;
4895
- return tafList.find(function (element) {
4896
- return element.taf.uuid === selectedTafId;
4897
- });
4898
- };
4899
-
4900
- var TafWrapper = function TafWrapper() {
4901
- var _useApiContext = useApiContext(),
4902
- api = _useApiContext.api;
4903
-
4904
- var confirmDialog = useConfirmationDialog();
4905
-
4906
- var _React$useState3 = React__default.useState(false),
4907
- _React$useState4 = _slicedToArray(_React$useState3, 2),
4908
- isTafDialogOpen = _React$useState4[0],
4909
- setTafDialogOpen = _React$useState4[1];
4910
-
4911
- var _React$useState5 = React__default.useState(null),
4912
- _React$useState6 = _slicedToArray(_React$useState5, 2),
4913
- selectedTafId = _React$useState6[0],
4914
- setselectedTafId = _React$useState6[1];
4897
+ var fromActionToStatus = function fromActionToStatus(tafAction) {
4898
+ switch (tafAction) {
4899
+ case 'DRAFT':
4900
+ return 'DRAFT';
4915
4901
 
4916
- var _React$useState7 = React__default.useState(null),
4917
- _React$useState8 = _slicedToArray(_React$useState7, 2),
4918
- tafDialogAction = _React$useState8[0],
4919
- setTafDialogAction = _React$useState8[1];
4902
+ case 'DRAFT_AMEND':
4903
+ return 'DRAFT_AMENDED';
4920
4904
 
4921
- var _React$useState9 = React__default.useState(false),
4922
- _React$useState10 = _slicedToArray(_React$useState9, 2),
4923
- errorPostMessage = _React$useState10[0],
4924
- setErrorPostMessage = _React$useState10[1];
4905
+ case 'DRAFT_CORRECT':
4906
+ return 'DRAFT_CORRECTED';
4925
4907
 
4926
- var _React$useState11 = React__default.useState(''),
4927
- _React$useState12 = _slicedToArray(_React$useState11, 2),
4928
- errorPostMessageText = _React$useState12[0],
4929
- setErrorPostMessageText = _React$useState12[1];
4908
+ case 'PUBLISH':
4909
+ return 'PUBLISHED';
4930
4910
 
4931
- var _React$useState13 = React__default.useState(false),
4932
- _React$useState14 = _slicedToArray(_React$useState13, 2),
4933
- showSpinner = _React$useState14[0],
4934
- setSpinner = _React$useState14[1]; // clear error message for cancel after 10 seconds
4911
+ case 'AMEND':
4912
+ return 'AMENDED';
4935
4913
 
4914
+ case 'CORRECT':
4915
+ return 'CORRECTED';
4936
4916
 
4937
- var _useTimeoutCancelErro = useTimeoutCancelError(),
4938
- _useTimeoutCancelErro2 = _slicedToArray(_useTimeoutCancelErro, 2),
4939
- errorCancelTaf = _useTimeoutCancelErro2[0],
4940
- setErrorCancelTaf = _useTimeoutCancelErro2[1]; // Retrieve list of tafs
4917
+ case 'CANCEL':
4918
+ return 'CANCELLED';
4941
4919
 
4920
+ default:
4921
+ return 'NEW';
4922
+ }
4923
+ };
4942
4924
 
4943
- var _useApi = useApi(api.getTafList),
4944
- errorList = _useApi.error,
4945
- isLoadingList = _useApi.isLoading,
4946
- tafList = _useApi.result,
4947
- fetchNewTafList = _useApi.fetchApiData;
4925
+ var TafPanel = function TafPanel(_ref) {
4926
+ var tafFromBackend = _ref.tafFromBackend,
4927
+ activeTafIndex = _ref.activeTafIndex,
4928
+ index = _ref.index,
4929
+ _ref$onPostTaf = _ref.onPostTaf,
4930
+ onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
4948
4931
 
4949
- var getNewTafList = function getNewTafList() {
4950
- fetchNewTafList({});
4951
- };
4932
+ var _useApiContext = useApiContext(),
4933
+ api = _useApiContext.api;
4952
4934
 
4953
- usePoller([tafList, errorList], getNewTafList);
4935
+ var _React$useState = React__default.useState(false),
4936
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4937
+ isLoading = _React$useState2[0],
4938
+ setLoading = _React$useState2[1];
4954
4939
 
4955
- var toggleTafDialog = function toggleTafDialog() {
4956
- // Refresh list on closing dialog
4957
- if (isTafDialogOpen === true) getNewTafList(); // Set error message back to false
4940
+ var _React$useState3 = React__default.useState(null),
4941
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
4942
+ error = _React$useState4[0],
4943
+ setError = _React$useState4[1]; // removes cancelled error message
4958
4944
 
4959
- setErrorPostMessage(false);
4960
- setErrorPostMessageText('');
4961
- setTafDialogOpen(!isTafDialogOpen);
4962
- };
4963
4945
 
4964
4946
  React__default.useEffect(function () {
4965
- if (selectedTafId) {
4966
- toggleTafDialog();
4967
- } // eslint-disable-next-line react-hooks/exhaustive-deps
4968
-
4969
- }, [selectedTafId]);
4970
-
4971
- var onClickTafActionButton = function onClickTafActionButton(action, tafUuid) {
4972
- if (action === 'CANCEL') {
4973
- confirmDialog({
4974
- title: 'Cancel TAF',
4975
- description: 'Are you sure you want to cancel this TAF?',
4976
- confirmLabel: 'Cancel'
4977
- }).then(function () {
4978
- var _getSelectedTaf = getSelectedTaf(tafUuid, tafList),
4979
- taf = _getSelectedTaf.taf;
4980
-
4981
- postTaf({
4982
- taf: taf,
4983
- changeStatusTo: 'CANCELLED'
4984
- });
4985
- });
4986
- } else if (selectedTafId === tafUuid) {
4987
- setTafDialogAction(action);
4988
- toggleTafDialog();
4989
- } else {
4990
- setTafDialogAction(action);
4991
- setselectedTafId(tafUuid);
4992
- }
4993
- };
4947
+ var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
4948
+ setError(null);
4949
+ }, 10000) : null;
4950
+ return function () {
4951
+ if (cancelErrorTimeout !== null) {
4952
+ clearTimeout(cancelErrorTimeout);
4953
+ }
4954
+ };
4955
+ }, [error]);
4994
4956
 
4995
4957
  var postTaf = function postTaf(data) {
4996
4958
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4959
+ var newError;
4997
4960
  return regeneratorRuntime.wrap(function _callee$(_context) {
4998
4961
  while (1) {
4999
4962
  switch (_context.prev = _context.next) {
5000
4963
  case 0:
5001
- setSpinner(true);
5002
- _context.prev = 1;
4964
+ _context.prev = 0;
4965
+ setLoading(true);
5003
4966
  _context.next = 4;
5004
4967
  return api.postTaf(data);
5005
4968
 
5006
4969
  case 4:
5007
- if (isTafDialogOpen) toggleTafDialog();
5008
- setSpinner(false); // fetch new taflist
4970
+ setLoading(false);
4971
+ setError(null); // callback
5009
4972
 
5010
- getNewTafList(); // If a post has succeeded remove error message
4973
+ onPostTaf();
4974
+ _context.next = 15;
4975
+ break;
5011
4976
 
5012
- setErrorCancelTaf([]);
5013
- _context.next = 14;
4977
+ case 9:
4978
+ _context.prev = 9;
4979
+ _context.t0 = _context["catch"](0);
4980
+ newError = data.changeStatusTo === 'CANCELLED' ? {
4981
+ type: 'CANCELLED',
4982
+ title: 'Cancelling this TAF failed, please try again'
4983
+ } : {
4984
+ type: 'SERVER',
4985
+ title: 'An error has occurred while saving, please try again',
4986
+ message: getAxiosErrorMessage(_context.t0)
4987
+ };
4988
+ setError(newError);
4989
+ setLoading(false);
4990
+ throw _context.t0;
4991
+
4992
+ case 15:
4993
+ case "end":
4994
+ return _context.stop();
4995
+ }
4996
+ }
4997
+ }, _callee, null, [[0, 9]]);
4998
+ }));
4999
+ };
5000
+
5001
+ var getViewMode = function getViewMode(status) {
5002
+ return status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED' ? 'edit' : 'view';
5003
+ };
5004
+
5005
+ var onTafAction = function onTafAction(action, taf) {
5006
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5007
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
5008
+ while (1) {
5009
+ switch (_context2.prev = _context2.next) {
5010
+ case 0:
5011
+ _context2.prev = 0;
5012
+ _context2.t0 = action;
5013
+ _context2.next = _context2.t0 === 'DRAFT' ? 4 : _context2.t0 === 'DRAFT_AMEND' ? 4 : _context2.t0 === 'DRAFT_CORRECT' ? 4 : _context2.t0 === 'PUBLISH' ? 4 : _context2.t0 === 'AMEND' ? 4 : _context2.t0 === 'CANCEL' ? 4 : _context2.t0 === 'CORRECT' ? 4 : 7;
5014
5014
  break;
5015
5015
 
5016
- case 10:
5017
- _context.prev = 10;
5018
- _context.t0 = _context["catch"](1);
5016
+ case 4:
5017
+ _context2.next = 6;
5018
+ return postTaf({
5019
+ taf: taf,
5020
+ changeStatusTo: fromActionToStatus(action)
5021
+ });
5019
5022
 
5020
- if (data.changeStatusTo === 'CANCELLED') {
5021
- setErrorCancelTaf([].concat(_toConsumableArray(errorCancelTaf), [data.taf.uuid]));
5022
- } else {
5023
- setErrorPostMessage(true);
5023
+ case 6:
5024
+ return _context2.abrupt("return", true);
5024
5025
 
5025
- if (isAxiosError(_context.t0)) {
5026
- setErrorPostMessageText(getAxiosErrorMessage(_context.t0));
5027
- }
5028
- }
5026
+ case 7:
5027
+ return _context2.abrupt("return", false);
5028
+
5029
+ case 8:
5030
+ _context2.next = 13;
5031
+ break;
5029
5032
 
5030
- setSpinner(false);
5033
+ case 10:
5034
+ _context2.prev = 10;
5035
+ _context2.t1 = _context2["catch"](0);
5036
+ return _context2.abrupt("return", false);
5031
5037
 
5032
- case 14:
5038
+ case 13:
5033
5039
  case "end":
5034
- return _context.stop();
5040
+ return _context2.stop();
5035
5041
  }
5036
5042
  }
5037
- }, _callee, null, [[1, 10]]);
5043
+ }, _callee2, null, [[0, 10]]);
5038
5044
  }));
5039
5045
  };
5040
5046
 
5041
- var fromActionToStatus = function fromActionToStatus(tafAction) {
5042
- switch (tafAction) {
5043
- case 'DRAFT':
5044
- return 'DRAFT';
5047
+ return /*#__PURE__*/React__default.createElement(TabPanel, {
5048
+ value: activeTafIndex,
5049
+ index: index,
5050
+ "data-testid": "taf-panel".concat(activeTafIndex === index ? '-active' : '')
5051
+ }, /*#__PURE__*/React__default.createElement(TafHeader, {
5052
+ title: getTafStatusLabel(tafFromBackend.taf.status)
5053
+ }), isLoading && /*#__PURE__*/React__default.createElement(Spinner, {
5054
+ "data-testid": "taf-loading",
5055
+ sx: {
5056
+ position: 'absolute',
5057
+ zIndex: 1,
5058
+ color: 'geowebColors.backdrops.white.fill'
5059
+ }
5060
+ }), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
5061
+ severity: "error",
5062
+ title: error.title,
5063
+ info: error.message,
5064
+ dataTestId: "taf-error"
5065
+ }), /*#__PURE__*/React__default.createElement(TafFormWrapper, {
5066
+ mode: getViewMode(tafFromBackend.taf.status),
5067
+ tafFromBackend: tafFromBackend,
5068
+ onFormAction: onTafAction
5069
+ }));
5070
+ };
5045
5071
 
5046
- case 'DRAFT_AMEND':
5047
- return 'DRAFT_AMENDED';
5072
+ var TafLayout = function TafLayout(_ref) {
5073
+ var _ref$tafList = _ref.tafList,
5074
+ tafList = _ref$tafList === void 0 ? [] : _ref$tafList,
5075
+ _ref$onPostTaf = _ref.onPostTaf,
5076
+ onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
5048
5077
 
5049
- case 'DRAFT_CORRECT':
5050
- return 'DRAFT_CORRECTED';
5078
+ var _React$useState = React__default.useState(sortTafTimeSlots(tafList)),
5079
+ _React$useState2 = _slicedToArray(_React$useState, 2),
5080
+ _React$useState2$ = _React$useState2[0],
5081
+ upcoming = _React$useState2$.upcoming,
5082
+ current = _React$useState2$.current,
5083
+ expired = _React$useState2$.expired,
5084
+ updateSortedTafs = _React$useState2[1];
5051
5085
 
5052
- case 'PUBLISH':
5053
- return 'PUBLISHED';
5086
+ var _upcoming$slice = upcoming.slice(-1),
5087
+ _upcoming$slice2 = _slicedToArray(_upcoming$slice, 1),
5088
+ lastUpcomingTaf = _upcoming$slice2[0];
5054
5089
 
5055
- case 'AMEND':
5056
- return 'AMENDED';
5090
+ var _React$useState3 = React__default.useState('UPCOMING'),
5091
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
5092
+ timeSlot = _React$useState4[0],
5093
+ setTimeSlot = _React$useState4[1];
5057
5094
 
5058
- case 'CORRECT':
5059
- return 'CORRECTED';
5095
+ var _React$useState5 = React__default.useState(upcoming),
5096
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
5097
+ locations = _React$useState6[0],
5098
+ setLocations = _React$useState6[1];
5060
5099
 
5061
- default:
5062
- return 'NEW';
5063
- }
5100
+ var _React$useState7 = React__default.useState(0),
5101
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
5102
+ activeTafIndex = _React$useState8[0],
5103
+ setActiveTafIndex = _React$useState8[1];
5104
+
5105
+ var onChangeTimeSlot = function onChangeTimeSlot(newTimeSlot) {
5106
+ setTimeSlot(newTimeSlot);
5107
+ setLocations(newTimeSlot === 'ACTIVE' ? current : upcoming);
5108
+ setActiveTafIndex(0);
5064
5109
  };
5065
5110
 
5066
- var onFormAction = function onFormAction(action, taf) {
5067
- // Add right actions and their follow up calls to the BE
5068
- switch (action) {
5069
- case 'CLOSE':
5070
- confirmDialog({
5071
- title: 'Closing TAF',
5072
- description: 'Are you sure you want to close this TAF? Any changes made will be lost.',
5073
- confirmLabel: 'Close'
5074
- }).then(function () {
5075
- toggleTafDialog();
5076
- });
5077
- break;
5111
+ React__default.useEffect(function () {
5112
+ var newSortedTafs = sortTafTimeSlots(tafList);
5113
+ var updatedLocations = timeSlot === 'ACTIVE' ? newSortedTafs.current : newSortedTafs.upcoming;
5114
+ updateSortedTafs(sortTafTimeSlots(tafList));
5115
+ setLocations(updatedLocations); // update active index
5078
5116
 
5079
- case 'DRAFT':
5080
- case 'DRAFT_AMEND':
5081
- case 'DRAFT_CORRECT':
5082
- case 'PUBLISH':
5083
- case 'AMEND':
5084
- case 'CORRECT':
5085
- postTaf({
5086
- taf: taf,
5087
- changeStatusTo: fromActionToStatus(action)
5088
- });
5089
- break;
5117
+ var newActiveIndex = updatedLocations.findIndex(function (location) {
5118
+ return location.taf.previousId === locations[activeTafIndex].taf.uuid;
5119
+ });
5120
+ var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
5121
+ setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5122
+ }, [tafList, setLocations]);
5090
5123
 
5091
- default:
5092
- toggleTafDialog();
5093
- break;
5124
+ if (!tafList) {
5125
+ return null;
5126
+ }
5127
+
5128
+ var activeTaf = locations[activeTafIndex];
5129
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
5130
+ id: MODAL_DIALOG_ELEMENT,
5131
+ component: "div",
5132
+ sx: {
5133
+ width: '100%',
5134
+ height: '100%',
5135
+ position: 'absolute',
5136
+ overflow: 'hidden',
5137
+ pointerEvents: 'none'
5138
+ }
5139
+ }), /*#__PURE__*/React__default.createElement(Box, {
5140
+ sx: {
5141
+ height: '100%',
5142
+ maxHeight: '100%'
5143
+ }
5144
+ }, /*#__PURE__*/React__default.createElement(Box, {
5145
+ sx: {
5146
+ minWidth: 320,
5147
+ maxWidth: 1272,
5148
+ margin: 'auto',
5149
+ height: '100%',
5150
+ display: 'flex',
5151
+ flexDirection: 'column'
5152
+ }
5153
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5154
+ container: true,
5155
+ spacing: 2,
5156
+ sx: {
5157
+ paddingLeft: 1,
5158
+ paddingRight: 1
5159
+ }
5160
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5161
+ item: true,
5162
+ xs: 12,
5163
+ sm: 9
5164
+ }, /*#__PURE__*/React__default.createElement(TopTabs, {
5165
+ tafFromBackend: lastUpcomingTaf,
5166
+ timeSlot: timeSlot,
5167
+ onChangeTimeSlot: onChangeTimeSlot
5168
+ }))), /*#__PURE__*/React__default.createElement(Grid, {
5169
+ container: true,
5170
+ flexGrow: 1,
5171
+ overflow: "hidden"
5172
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5173
+ container: true,
5174
+ spacing: 2,
5175
+ sx: {
5176
+ height: '100%',
5177
+ paddingLeft: 1,
5178
+ paddingRight: 1,
5179
+ paddingTop: 2,
5180
+ overflow: 'auto'
5181
+ }
5182
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5183
+ item: true,
5184
+ xs: 3,
5185
+ sm: 1
5186
+ }, /*#__PURE__*/React__default.createElement(LocationTabs, {
5187
+ tafList: locations,
5188
+ activeIndex: activeTafIndex,
5189
+ onChangeTab: setActiveTafIndex,
5190
+ timeSlot: timeSlot
5191
+ })), /*#__PURE__*/React__default.createElement(Grid, {
5192
+ item: true,
5193
+ xs: true
5194
+ }, /*#__PURE__*/React__default.createElement(Card, {
5195
+ variant: "outlined",
5196
+ sx: {
5197
+ padding: 1,
5198
+ paddingTop: 0,
5199
+ marginBottom: '12px',
5200
+ position: 'relative'
5094
5201
  }
5202
+ }, /*#__PURE__*/React__default.createElement(TacOverviewMobile, {
5203
+ upcomingTafs: upcoming,
5204
+ currentTafs: current,
5205
+ expiredTafs: expired,
5206
+ activeTaf: activeTaf
5207
+ }), locations.map(function (tafFromBackend, index) {
5208
+ return /*#__PURE__*/React__default.createElement(TafPanel, {
5209
+ key: tafFromBackend.taf.uuid,
5210
+ activeTafIndex: activeTafIndex,
5211
+ index: index,
5212
+ tafFromBackend: tafFromBackend,
5213
+ onPostTaf: onPostTaf
5214
+ });
5215
+ }))), /*#__PURE__*/React__default.createElement(Grid, {
5216
+ item: true,
5217
+ xs: 3,
5218
+ sx: {
5219
+ height: '100%'
5220
+ },
5221
+ display: {
5222
+ xs: 'none',
5223
+ sm: 'block'
5224
+ }
5225
+ }, /*#__PURE__*/React__default.createElement(TacOverview, {
5226
+ upcomingTafs: upcoming,
5227
+ currentTafs: current,
5228
+ expiredTafs: expired,
5229
+ activeTaf: activeTaf
5230
+ })))))));
5231
+ };
5232
+
5233
+ var TafModule = function TafModule() {
5234
+ var _useApiContext = useApiContext(),
5235
+ api = _useApiContext.api;
5236
+
5237
+ var _React$useState = React.useState(false),
5238
+ _React$useState2 = _slicedToArray(_React$useState, 2),
5239
+ isLoading = _React$useState2[0],
5240
+ setLoading = _React$useState2[1];
5241
+
5242
+ var _useApi = useApi(api.getTafList),
5243
+ getTafListError = _useApi.error,
5244
+ isFetchingInitial = _useApi.isLoading,
5245
+ tafList = _useApi.result,
5246
+ fetchNewTafList = _useApi.fetchApiData;
5247
+
5248
+ usePoller([tafList, getTafListError], function () {
5249
+ return fetchNewTafList({});
5250
+ });
5251
+
5252
+ var reFetchNewTafList = function reFetchNewTafList() {
5253
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
5254
+ return regeneratorRuntime.wrap(function _callee$(_context) {
5255
+ while (1) {
5256
+ switch (_context.prev = _context.next) {
5257
+ case 0:
5258
+ _context.prev = 0;
5259
+ setLoading(true);
5260
+ _context.next = 4;
5261
+ return fetchNewTafList({});
5262
+
5263
+ case 4:
5264
+ setLoading(false);
5265
+ _context.next = 10;
5266
+ break;
5267
+
5268
+ case 7:
5269
+ _context.prev = 7;
5270
+ _context.t0 = _context["catch"](0);
5271
+ setLoading(false);
5272
+
5273
+ case 10:
5274
+ case "end":
5275
+ return _context.stop();
5276
+ }
5277
+ }
5278
+ }, _callee, null, [[0, 7]]);
5279
+ }));
5095
5280
  };
5096
5281
 
5097
- var selectedTaf = getSelectedTaf(selectedTafId, tafList);
5098
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafList, {
5282
+ var hasTafListError = getTafListError !== null;
5283
+
5284
+ if (isFetchingInitial) {
5285
+ return /*#__PURE__*/React.createElement(LinearProgress, {
5286
+ color: "secondary",
5287
+ "data-testid": "loading-bar"
5288
+ });
5289
+ }
5290
+
5291
+ return /*#__PURE__*/React.createElement(Box, {
5292
+ component: "div",
5293
+ id: "tafmodule",
5294
+ sx: {
5295
+ height: '100%'
5296
+ }
5297
+ }, isLoading && /*#__PURE__*/React.createElement(LinearProgress, {
5298
+ "data-testid": "loading-bar",
5299
+ color: "secondary",
5300
+ sx: {
5301
+ marginBottom: '-4px'
5302
+ }
5303
+ }), hasTafListError && /*#__PURE__*/React.createElement(AlertBanner, {
5304
+ severity: "error",
5305
+ title: "An error has occurred while retrieving the list",
5306
+ info: getTafListError.message
5307
+ }), /*#__PURE__*/React.createElement(TafLayout, {
5099
5308
  tafList: tafList,
5100
- isLoading: isLoadingList,
5101
- error: errorList,
5102
- onClickTafActionButton: onClickTafActionButton,
5103
- errorCancelTaf: errorCancelTaf
5104
- }), showSpinner && /*#__PURE__*/React__default.createElement(Spinner, null), selectedTaf !== undefined && /*#__PURE__*/React__default.createElement(TafFormDialog, {
5105
- open: isTafDialogOpen,
5106
- toggleFormDialog: toggleTafDialog,
5107
- tafFromBackend: selectedTaf,
5108
- alertBanner: errorPostMessage ? /*#__PURE__*/React__default.createElement(AlertBanner, {
5109
- severity: "error",
5110
- title: "An error has occurred while saving, please try again",
5111
- info: errorPostMessageText
5112
- }) : null,
5113
- onFormAction: onFormAction
5114
- }, /*#__PURE__*/React__default.createElement(TafFormWrapper, {
5115
- mode: "edit",
5116
- tafFromBackend: selectedTaf,
5117
- tafAction: tafDialogAction,
5118
- onFormAction: onFormAction
5119
- }), showSpinner && /*#__PURE__*/React__default.createElement(Spinner, null)));
5309
+ onPostTaf: reFetchNewTafList
5310
+ }));
5120
5311
  };
5121
- /**
5122
- * Shows the list of Tafs and allows to create, edit and view Tafs.
5123
- * Needs to be wrapped in the ApiProvider.
5124
- *
5125
- * @example
5126
- * ```<ApiProvider baseURL="http://test.com" appURL="http://app.com" auth={auth} onSetAuth={onSetAuth} createApi={createApi}> authTokenUrl="url/tokenrefresh"<TafWrapper /> </ApiProvider>```
5127
- */
5128
-
5129
5312
 
5130
- var ConfirmationWrapper = function ConfirmationWrapper() {
5131
- return /*#__PURE__*/React__default.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React__default.createElement(TafWrapper, null));
5313
+ var Wrapper = function Wrapper() {
5314
+ return /*#__PURE__*/React.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React.createElement(TafModule, null));
5132
5315
  };
5133
5316
 
5134
5317
  /* *
@@ -5163,4 +5346,4 @@ var createApi = function createApi(url, appUrl, auth, setAuth, authTokenUrl, aut
5163
5346
  };
5164
5347
  };
5165
5348
 
5166
- export { ContentDialog, TafFormDialog, TafFormWrapper, TafList, TafListRow, TafListSection, ConfirmationWrapper as TafWrapper, createApi };
5349
+ export { TafFormWrapper, Wrapper as TafModule, createApi };