@opengeoweb/warnings 9.27.1 → 9.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -180,7 +180,11 @@ var en = {
180
180
  "aviation-phenomenon-occasional-towering-cumulus-cloud": "Occasional towering cumulus cloud",
181
181
  "aviation-phenomenon-frequent-towering-cumulus-cloud": "Frequent towering cumulus cloud",
182
182
  "aviation-phenomenon-moderate-mountain-wave": "Moderate mountain wave",
183
- "aviation-phenomenon-mountains-obscured": "Mountains obscured"
183
+ "aviation-phenomenon-mountains-obscured": "Mountains obscured",
184
+ "warning-dialog-expire-succes": "Warning has been expired",
185
+ "warning-dialog-expire-title": "Expire warning",
186
+ "warning-dialog-expire-confirm": "Expire",
187
+ "warning-dialog-expire-description": "Are you sure you want to expire this warning?"
184
188
  };
185
189
  var nl = {
186
190
  "drawing-tool-form-tools": "Gereedschap",
@@ -302,7 +306,11 @@ var nl = {
302
306
  "filter-phenomenon": "Fenomenen",
303
307
  "filter-level": "Niveaus",
304
308
  "filter-source": "Bronnen",
305
- "error-title-retry": "Probeer opnieuw"
309
+ "error-title-retry": "Probeer opnieuw",
310
+ "warning-dialog-expire-succes": "Waarschuwing laten verlopen is succesvol",
311
+ "warning-dialog-expire-title": "Waarschuwing laten verlopen",
312
+ "warning-dialog-expire-confirm": "Verlopen",
313
+ "warning-dialog-expire-description": "Weet je zeker dat je deze waarschuwing wilt laten verlopen?"
306
314
  };
307
315
  var fi = {
308
316
  "drawing-tool-form-tools": "Työkalut",
@@ -424,7 +432,11 @@ var fi = {
424
432
  "filter-phenomenon": "ei käännetty",
425
433
  "filter-level": "ei käännetty",
426
434
  "filter-source": "ei käännetty",
427
- "error-title-retry": "Yritä uudelleen"
435
+ "error-title-retry": "Yritä uudelleen",
436
+ "warning-dialog-expire-succes": "ei käännetty",
437
+ "warning-dialog-expire-title": "ei käännetty",
438
+ "warning-dialog-expire-confirm": "ei käännetty",
439
+ "warning-dialog-expire-description": "ei käännetty"
428
440
  };
429
441
  var no = {
430
442
  "drawing-tool-form-tools": "Verktøy",
@@ -546,7 +558,11 @@ var no = {
546
558
  "filter-phenomenon": "Fenomen",
547
559
  "filter-level": "Grad",
548
560
  "filter-source": "Kilder",
549
- "error-title-retry": "Prøv igjen"
561
+ "error-title-retry": "Prøv igjen",
562
+ "warning-dialog-expire-succes": "ikke oversatt",
563
+ "warning-dialog-expire-title": "ikke oversatt",
564
+ "warning-dialog-expire-confirm": "ikke oversatt",
565
+ "warning-dialog-expire-description": "ikke oversatt"
550
566
  };
551
567
  var warningsTranslations = {
552
568
  en: en,
@@ -11045,8 +11061,8 @@ const AreaField = ({
11045
11061
  }, {
11046
11062
  children: [jsx(Typography, Object.assign({
11047
11063
  variant: "h4",
11048
- color: "text.primary",
11049
11064
  sx: {
11065
+ color: 'text.primary',
11050
11066
  fontSize: '0.75rem',
11051
11067
  fontWeight: 'normal',
11052
11068
  lineHeight: 1.83
@@ -11056,7 +11072,9 @@ const AreaField = ({
11056
11072
  children: objectName
11057
11073
  })), jsx(Typography, Object.assign({
11058
11074
  variant: "body2",
11059
- color: "text.secondary"
11075
+ sx: {
11076
+ color: 'text.secondary'
11077
+ }
11060
11078
  }, {
11061
11079
  children: lastUpdatedTime ? formatDate(lastUpdatedTime) : ''
11062
11080
  })), geoJSON ? jsx(ToggleMenu, {
@@ -14123,7 +14141,7 @@ const transformAirmetToWarningFormat = apiAirmet => {
14123
14141
  descriptionTranslation: '',
14124
14142
  areas: [{
14125
14143
  geoJSON: airmet.startGeometry,
14126
- objectName: ''
14144
+ objectName: airmet.locationIndicatorATSR
14127
14145
  }],
14128
14146
  phenomenon: airmet.phenomenon,
14129
14147
  validFrom: airmet.validDateStart,
@@ -14145,7 +14163,7 @@ const transformSigmetToWarningFormat = apiSigmet => {
14145
14163
  descriptionTranslation: '',
14146
14164
  areas: [{
14147
14165
  geoJSON: sigmet.startGeometry,
14148
- objectName: ''
14166
+ objectName: sigmet.locationIndicatorATSR
14149
14167
  }],
14150
14168
  phenomenon: sigmet.phenomenon,
14151
14169
  validFrom: sigmet.validDateStart,
@@ -14170,6 +14188,23 @@ const mapProductStatusToWarningStatus = productStatus => {
14170
14188
  }
14171
14189
  };
14172
14190
 
14191
+ function useOverflowCheck(text) {
14192
+ const ref = React__default.useRef(null);
14193
+ const [isOverflowing, setIsOverflowing] = React__default.useState(false);
14194
+ React__default.useEffect(() => {
14195
+ const checkOverflow = () => {
14196
+ if (ref.current) {
14197
+ setIsOverflowing(ref.current.scrollWidth > ref.current.clientWidth);
14198
+ }
14199
+ };
14200
+ checkOverflow();
14201
+ }, [text]);
14202
+ return {
14203
+ ref,
14204
+ isOverflowing
14205
+ };
14206
+ }
14207
+
14173
14208
  const getSortedStatus = status => {
14174
14209
  switch (status) {
14175
14210
  case 'DRAFT_PUBLISHED':
@@ -14312,6 +14347,7 @@ const getMenuItems = ({
14312
14347
  onEditWarning: _onEditWarning = () => {},
14313
14348
  onDeleteWarning: _onDeleteWarning = () => {},
14314
14349
  onDeleteReviewWarning: _onDeleteReviewWarning = () => {},
14350
+ onExpireWarning: _onExpireWarning = () => {},
14315
14351
  t
14316
14352
  }) => {
14317
14353
  const duplicate = {
@@ -14319,6 +14355,8 @@ const getMenuItems = ({
14319
14355
  action: () => _onEditWarning(getWarningWithoutIdStatusEditor(warning)),
14320
14356
  icon: jsx(Copy, {})
14321
14357
  };
14358
+ // disable Expire option if warning is not active
14359
+ const shouldDisableExpire = !dateUtils.isBetween(dateUtils.getNowUtc(), dateUtils.createDate(warning.warningDetail.validFrom), dateUtils.createDate(warning.warningDetail.validUntil), '[]');
14322
14360
  switch (warning.status) {
14323
14361
  case 'PUBLISHED':
14324
14362
  return [{
@@ -14327,9 +14365,9 @@ const getMenuItems = ({
14327
14365
  icon: jsx(Edit, {})
14328
14366
  }, duplicate, {
14329
14367
  text: t('warning-list-button-expire'),
14330
- action: () => null,
14368
+ action: () => _onExpireWarning(warning),
14331
14369
  icon: jsx(Expire, {}),
14332
- isDisabled: true
14370
+ isDisabled: shouldDisableExpire
14333
14371
  }, {
14334
14372
  text: t('warning-list-button-withdraw'),
14335
14373
  action: () => null,
@@ -14364,6 +14402,7 @@ const getMenuItems = ({
14364
14402
  }
14365
14403
  };
14366
14404
  const WarningListItem = _a => {
14405
+ var _b, _c;
14367
14406
  var {
14368
14407
  warning,
14369
14408
  status,
@@ -14371,26 +14410,25 @@ const WarningListItem = _a => {
14371
14410
  onSelectWarning = () => {},
14372
14411
  onEditWarning = () => {},
14373
14412
  onDeleteWarning = () => {},
14374
- onDeleteReviewWarning = () => {}
14413
+ onDeleteReviewWarning = () => {},
14414
+ onExpireWarning = () => {}
14375
14415
  } = _a,
14376
- props = __rest(_a, ["warning", "status", "activeWarningId", "onSelectWarning", "onEditWarning", "onDeleteWarning", "onDeleteReviewWarning"]);
14416
+ props = __rest(_a, ["warning", "status", "activeWarningId", "onSelectWarning", "onEditWarning", "onDeleteWarning", "onDeleteReviewWarning", "onExpireWarning"]);
14377
14417
  const {
14378
14418
  t
14379
14419
  } = useWarningsTranslation();
14380
14420
  const phenomenonDetails = allPhenomenaDict[warning.warningDetail.phenomenon];
14421
+ const objectNameText = ((_c = (_b = warning.warningDetail.areas) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.objectName) || '-';
14422
+ const {
14423
+ ref: objectNameRef,
14424
+ isOverflowing: isObjectNameOverflowing
14425
+ } = useOverflowCheck(objectNameText);
14426
+ const phenomenonText = (phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) ? t(phenomenonDetails.translationKey) : '-';
14427
+ const {
14428
+ ref: phenomenonRef,
14429
+ isOverflowing: isPhenomenonOverflowing
14430
+ } = useOverflowCheck(phenomenonText);
14381
14431
  const levelDetails = levelOptionsDict[warning.warningDetail.level];
14382
- // State and effect to track if the phenomena text is overflowing
14383
- const textRef = useRef(null);
14384
- const [isOverflowing, setIsOverflowing] = useState(false);
14385
- useEffect(() => {
14386
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
14387
- const checkOverflow = () => {
14388
- if (textRef.current) {
14389
- setIsOverflowing(textRef.current.scrollWidth > textRef.current.clientWidth);
14390
- }
14391
- };
14392
- checkOverflow();
14393
- }, [phenomenonDetails]);
14394
14432
  return jsx(ListItem, Object.assign({
14395
14433
  sx: {
14396
14434
  marginBottom: 0.25,
@@ -14412,7 +14450,8 @@ const WarningListItem = _a => {
14412
14450
  t,
14413
14451
  onEditWarning,
14414
14452
  onDeleteReviewWarning,
14415
- onDeleteWarning
14453
+ onDeleteWarning,
14454
+ onExpireWarning
14416
14455
  }),
14417
14456
  buttonIcon: jsx(Options, {})
14418
14457
  }),
@@ -14491,7 +14530,7 @@ const WarningListItem = _a => {
14491
14530
  children: [jsx(Box, Object.assign({
14492
14531
  display: "inline-block",
14493
14532
  component: "div",
14494
- ref: textRef,
14533
+ ref: phenomenonRef,
14495
14534
  sx: {
14496
14535
  textOverflow: 'ellipsis',
14497
14536
  overflow: 'hidden',
@@ -14499,22 +14538,19 @@ const WarningListItem = _a => {
14499
14538
  whiteSpace: 'nowrap'
14500
14539
  }
14501
14540
  }, {
14502
- children: (() => {
14503
- if (isOverflowing) {
14504
- return jsx(CustomTooltip, Object.assign({
14505
- title: (phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) ? t(phenomenonDetails.translationKey) : '-',
14506
- placement: "top",
14507
- sx: {
14508
- zIndex: 1000
14509
- }
14510
- }, {
14511
- children: jsx("span", {
14512
- children: (phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) ? t(phenomenonDetails.translationKey) : '-'
14513
- })
14514
- }));
14541
+ children: isPhenomenonOverflowing ? jsx(CustomTooltip, Object.assign({
14542
+ title: phenomenonText,
14543
+ placement: "top",
14544
+ sx: {
14545
+ zIndex: 1000
14515
14546
  }
14516
- return (phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) ? t(phenomenonDetails.translationKey) : '-';
14517
- })()
14547
+ }, {
14548
+ children: jsx("span", {
14549
+ children: phenomenonText
14550
+ })
14551
+ })) : jsx("span", {
14552
+ children: phenomenonText
14553
+ })
14518
14554
  })), jsx(Box, Object.assign({
14519
14555
  sx: {
14520
14556
  position: 'absolute',
@@ -14554,6 +14590,35 @@ const WarningListItem = _a => {
14554
14590
  return '-';
14555
14591
  })()
14556
14592
  }))
14593
+ })), jsx(WarningListColumnContent, Object.assign({
14594
+ title: t('areas'),
14595
+ status: status
14596
+ }, {
14597
+ children: jsx(Box, Object.assign({
14598
+ display: "inline-block",
14599
+ component: "div",
14600
+ ref: objectNameRef,
14601
+ sx: {
14602
+ textOverflow: 'ellipsis',
14603
+ overflow: 'hidden',
14604
+ width: 70,
14605
+ whiteSpace: 'nowrap'
14606
+ }
14607
+ }, {
14608
+ children: isObjectNameOverflowing ? jsx(CustomTooltip, Object.assign({
14609
+ title: objectNameText,
14610
+ placement: "top",
14611
+ sx: {
14612
+ zIndex: 1000
14613
+ }
14614
+ }, {
14615
+ children: jsx("span", {
14616
+ children: objectNameText
14617
+ })
14618
+ })) : jsx("span", {
14619
+ children: objectNameText
14620
+ })
14621
+ }))
14557
14622
  })), jsx(WarningListColumnContent, Object.assign({
14558
14623
  title: t('warning-list-header-status'),
14559
14624
  status: status,
@@ -14683,6 +14748,7 @@ const PublicWarningList = ({
14683
14748
  onRefetchWarnings: _onRefetchWarnings = () => {},
14684
14749
  onDeleteReviewWarning: _onDeleteReviewWarning = () => {},
14685
14750
  onClickAllChip: _onClickAllChip = () => {},
14751
+ onExpireWarning: _onExpireWarning = () => {},
14686
14752
  isAllChipSelected: _isAllChipSelected = true
14687
14753
  }) => {
14688
14754
  const {
@@ -14873,9 +14939,12 @@ const PublicWarningList = ({
14873
14939
  width: 140
14874
14940
  }), jsx(WarningListHeaderContent, {
14875
14941
  title: t('warning-list-header-level')
14942
+ }), jsx(WarningListHeaderContent, {
14943
+ title: t('areas'),
14944
+ width: 100
14876
14945
  }), jsx(WarningListHeaderContent, {
14877
14946
  title: t('warning-list-header-status'),
14878
- width: 96,
14947
+ width: 76,
14879
14948
  sx: {
14880
14949
  marginRight: '48px'
14881
14950
  }
@@ -14925,7 +14994,8 @@ const PublicWarningList = ({
14925
14994
  onEditWarning: _onEditWarning,
14926
14995
  onDeleteWarning: _onDeleteWarning,
14927
14996
  onDeleteReviewWarning: _onDeleteReviewWarning,
14928
- activeWarningId: _selectedPublicWarningId
14997
+ activeWarningId: _selectedPublicWarningId,
14998
+ onExpireWarning: _onExpireWarning
14929
14999
  }, key);
14930
15000
  }
14931
15001
  }))
@@ -15137,6 +15207,7 @@ const PublicWarningListConnect = () => {
15137
15207
  const error = useSelector(getPublicWarningsError);
15138
15208
  const isFormDirty = useSelector(getSelectedPublicIsFormDirty);
15139
15209
  const lastUpdatedTime = useSelector(getPublicWarningsLastUpdatedTime);
15210
+ const warningsApi = getWarningsApi();
15140
15211
  const openPublicWarningDialog = (formAction, publicWarning) => __awaiter(void 0, void 0, void 0, function* () {
15141
15212
  if (isFormDirty) {
15142
15213
  const mayProceed = yield confirmDialog(warningFormConfirmationOptions(t)).then(() => true).catch(() => false);
@@ -15170,12 +15241,23 @@ const PublicWarningListConnect = () => {
15170
15241
  openPublicWarningDialog('', publicWarning);
15171
15242
  }
15172
15243
  });
15244
+ const expireWarning = warning => __awaiter(void 0, void 0, void 0, function* () {
15245
+ const expiredWarning = Object.assign(Object.assign({}, warning), {
15246
+ status: PublicWarningStatus.EXPIRED
15247
+ });
15248
+ setConfirmDialogOptions({
15249
+ confirmLabel: t('warning-dialog-expire-confirm'),
15250
+ title: t('warning-dialog-expire-title'),
15251
+ description: t('warning-dialog-expire-description'),
15252
+ request: () => warningsApi.updateWarning(expiredWarning.id, expiredWarning),
15253
+ callback: () => onRemoveSuccess(expiredWarning.id, t('warning-dialog-expire-succes'))
15254
+ });
15255
+ });
15173
15256
  const openSnackbar = message => {
15174
15257
  dispatch(snackbarActions.openSnackbar({
15175
15258
  message
15176
15259
  }));
15177
15260
  };
15178
- const warningsApi = getWarningsApi();
15179
15261
  const deleteWarning = (warningId, warningEditor) => {
15180
15262
  const isLocked = warningEditor && warningEditor !== (auth === null || auth === void 0 ? void 0 : auth.username) || false;
15181
15263
  setConfirmDialogOptions({
@@ -15248,6 +15330,7 @@ const PublicWarningListConnect = () => {
15248
15330
  onEditWarning: editWarning,
15249
15331
  onDeleteWarning: deleteWarning,
15250
15332
  onDeleteReviewWarning: deleteReviewWarning,
15333
+ onExpireWarning: expireWarning,
15251
15334
  selectedPublicWarningId: selectedPublicWarningId,
15252
15335
  lastUpdatedTime: lastUpdatedTime,
15253
15336
  onRefetchWarnings: fetchWarnings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "9.27.1",
3
+ "version": "9.28.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "@opengeoweb/authentication": "*",
29
29
  "react-i18next": "^14.1.2",
30
30
  "i18next": "^23.11.5",
31
- "@mui/material": "^5.16.0",
31
+ "@mui/material": "^6.1.1",
32
32
  "immer": "^10.0.3"
33
33
  },
34
34
  "peerDependencies": {
@@ -7,6 +7,7 @@ interface WarningStatusProps {
7
7
  onEditWarning?: (warning: PublicWarning) => void;
8
8
  onDeleteWarning?: (warningId: string, warningEditor?: string) => void;
9
9
  onDeleteReviewWarning?: (warning: PublicWarning) => void;
10
+ onExpireWarning?: (warning: PublicWarning) => void;
10
11
  }
11
12
  export declare const PublicWarningList: React.FC<{
12
13
  isLoading?: boolean;
@@ -1,4 +1,4 @@
1
- import { GridProps, ListItemProps } from '@mui/material';
1
+ import { Grid2Props, ListItemProps } from '@mui/material';
2
2
  import React from 'react';
3
3
  import { PublicWarning, PublicWarningStatus } from '../../store/publicWarningForm/types';
4
4
  export interface WarningStatusProps extends ListItemProps {
@@ -7,11 +7,12 @@ export interface WarningStatusProps extends ListItemProps {
7
7
  onEditWarning?: (warning: PublicWarning) => void;
8
8
  onDeleteWarning?: (warningId: string, warningEditor?: string) => void;
9
9
  onDeleteReviewWarning?: (warning: PublicWarning) => void;
10
+ onExpireWarning?: (warning: PublicWarning) => void;
10
11
  }
11
12
  export declare const getWarningWithoutIdStatusEditor: (warning: PublicWarning) => PublicWarning;
12
13
  export declare const getWarningWithLinkedToId: (warning: PublicWarning) => PublicWarning;
13
14
  export declare const getWarningWithProposalId: (warning: PublicWarning) => PublicWarning;
14
- export declare const WarningListColumnContent: React.FC<GridProps & {
15
+ export declare const WarningListColumnContent: React.FC<Grid2Props & {
15
16
  title?: string;
16
17
  status: PublicWarningStatus;
17
18
  children?: React.ReactNode;
@@ -0,0 +1,7 @@
1
+ import { RefObject } from 'react';
2
+ interface OverflowCheckResult {
3
+ ref: RefObject<HTMLDivElement>;
4
+ isOverflowing: boolean;
5
+ }
6
+ export default function useOverflowCheck(text: string): OverflowCheckResult;
7
+ export {};
@@ -0,0 +1 @@
1
+ export {};