@opengeoweb/workspace 9.25.2 → 9.26.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.css CHANGED
@@ -13,6 +13,7 @@
13
13
  *
14
14
  * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
15
15
  * Copyright 2022 - Finnish Meteorological Institute (FMI)
16
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
16
17
  * */
17
18
 
18
19
  /* This is to override some of the styling from mosaic-window (@blueprintjs under the hood), remove this when we have custom styling for workspace */
package/index.esm.js CHANGED
@@ -3,19 +3,19 @@ import _, { chunk, cloneDeep, isEmpty, isEqual, isString } from 'lodash';
3
3
  import { syncGroupsTypes, syncGroupsActions, layerActions, mapStoreActions, uiActions, genericActions, mapActions, layerTypes, mapEnums, selectorMemoizationOptions, genericSelectors, mapSelectors, syncGroupsSelectors, routerActions, coreModuleConfig, loadingIndicatorSelectors, uiSelectors } from '@opengeoweb/store';
4
4
  import { createApiInstance, createNonAuthApiInstance, getApi, createFakeApiInstance, ApiProvider, useApiContext } from '@opengeoweb/api';
5
5
  import { getLeaves, MosaicContext, getAndAssertNodeAtPathExists, createBalancedTreeFromLeaves, MosaicWindow, Mosaic } from 'react-mosaic-component';
6
+ import { SHARED_NAMESPACE, sharedTranslations, PROJECTION, isAxiosAuthError, getAxiosErrorMessage, isAxiosError, withEggs, ConfirmationServiceProvider, useConfirmationDialog, CustomIconButton, AlertBanner, CustomTooltip, SearchHighlight, ToggleMenu, DEFAULT_FILTER_HEIGHT, usePrevious, Filter, Resizable, ToolContainer, renderCounter, CustomToggleButton, ConfirmationDialog } from '@opengeoweb/shared';
6
7
  import i18n from 'i18next';
7
- import { SHARED_NAMESPACE, sharedTranslations, isAxiosAuthError, getAxiosErrorMessage, isAxiosError, withEggs, ConfirmationServiceProvider, useConfirmationDialog, CustomIconButton, AlertBanner, CustomTooltip, SearchHighlight, ToggleMenu, DEFAULT_FILTER_HEIGHT, usePrevious, Filter, Resizable, ToolContainer, renderCounter, CustomToggleButton, ConfirmationDialog } from '@opengeoweb/shared';
8
8
  import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations } from '@opengeoweb/webmap-react';
9
9
  import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
10
10
  import { CORE_NAMESPACE, coreTranslations } from '@opengeoweb/core';
11
11
  import { FORM_FIELDS_NAMESPACE, formFieldsTranslations, ReactHookFormTextField, ReactHookFormHiddenInput, ReactHookFormProvider, defaultFormOptions } from '@opengeoweb/form-fields';
12
+ import { timeSeriesSelectors, timeSeriesModuleConfig } from '@opengeoweb/timeseries';
12
13
  import { takeLatest, takeEvery, debounce, delay, put, all, select, call as call$g, takeLeading } from 'redux-saga/effects';
13
14
  import { snackbarActions, SnackbarWrapperConnect } from '@opengeoweb/snackbar';
14
15
  import { isAxiosError as isAxiosError$1 } from 'axios';
15
16
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
16
17
  import { ThemeWrapper, lightTheme, SplitVertical, SplitHorizontal, Expand, UnExpand, Close, Delete, Preset, PresetWorkspace, PresetTiles, CloudLoading, CloudIdle, WebAssetOff } from '@opengeoweb/theme';
17
18
  import { Provider, useDispatch, useSelector, useStore, shallowEqual } from 'react-redux';
18
- import { timeSeriesModuleConfig } from '@opengeoweb/timeseries';
19
19
  import { AuthenticationProvider, useAuthenticationContext } from '@opengeoweb/authentication';
20
20
  import { createStore } from '@redux-eggs/redux-toolkit';
21
21
  import { getSagaExtension } from '@redux-eggs/saga-extension';
@@ -1701,6 +1701,7 @@ $$7({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
1701
1701
  *
1702
1702
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1703
1703
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1704
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1704
1705
  * */
1705
1706
  var WorkspacePresetAction;
1706
1707
  (function (WorkspacePresetAction) {
@@ -3528,6 +3529,7 @@ fixRegExpWellKnownSymbolLogic$2('split', function (SPLIT, nativeSplit, maybeCall
3528
3529
  *
3529
3530
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3530
3531
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
3532
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3531
3533
  * */
3532
3534
  const getCleanSearchQuery = searchQuery => searchQuery.trim().split(/\s+/).join();
3533
3535
 
@@ -3628,7 +3630,7 @@ const emptyMapWorkspace = Object.assign(Object.assign({}, getEmptyWorkspaceListI
3628
3630
  right: 3967387.5161,
3629
3631
  top: 11520588.9031
3630
3632
  },
3631
- srs: 'EPSG:3857'
3633
+ srs: PROJECTION.EPSG_3857.value
3632
3634
  },
3633
3635
  shouldShowLayerManager: true,
3634
3636
  dockedLayerManagerSize: 'sizeSmall'
@@ -3660,7 +3662,7 @@ const getEmptyWorkspacePreset = () => ({
3660
3662
  right: 3967387.5161,
3661
3663
  top: 11520588.9031
3662
3664
  },
3663
- srs: 'EPSG:3857'
3665
+ srs: PROJECTION.EPSG_3857.value
3664
3666
  },
3665
3667
  shouldShowLayerManager: true,
3666
3668
  dockedLayerManagerSize: 'sizeSmall'
@@ -3964,6 +3966,7 @@ const workspaceActions = Object.assign({}, slice$1.actions);
3964
3966
  *
3965
3967
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3966
3968
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
3969
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3967
3970
  * */
3968
3971
  const getViewPresetsStore = store => {
3969
3972
  if (store && store.viewPresets) {
@@ -4048,14 +4051,34 @@ const getSnackbarMessage = (action, title) => {
4048
4051
  });
4049
4052
  }
4050
4053
  };
4051
- const emptyMapViewPreset = {
4052
- componentType: 'Map',
4053
- keywords: '',
4054
- scope: 'user',
4055
- title: '',
4056
- initialProps: {
4057
- mapPreset: {}
4058
- }
4054
+ const emptyViewPreset = (componentType = 'Map') => {
4055
+ const actualComponentType = componentType || 'Map';
4056
+ const initialPropsByType = {
4057
+ Map: {
4058
+ mapPreset: {}
4059
+ },
4060
+ TimeSeries: {
4061
+ plotPreset: {
4062
+ mapId: '',
4063
+ plots: [],
4064
+ parameters: []
4065
+ },
4066
+ services: []
4067
+ },
4068
+ ViewError: undefined,
4069
+ ViewLoading: undefined,
4070
+ MultiMap: undefined,
4071
+ ModelRunInterval: undefined,
4072
+ HarmonieTempAndPrecipPreset: undefined,
4073
+ TimeSlider: undefined
4074
+ };
4075
+ return {
4076
+ componentType: actualComponentType,
4077
+ keywords: '',
4078
+ scope: 'user',
4079
+ title: '',
4080
+ initialProps: initialPropsByType[actualComponentType]
4081
+ };
4059
4082
  };
4060
4083
  // Returns object of applied user filters such as scope/search etc
4061
4084
  // If all filter chips are selected, an empty string is returned for that filter which is interpreted in the BE as "return all" _
@@ -4193,17 +4216,23 @@ const getWorkspaceData = createSelector(getWorkspaceState, getViewPresetsStore,
4193
4216
  mosaicNode: store.mosaicNode
4194
4217
  };
4195
4218
  }, selectorMemoizationOptions);
4196
- const getViewPresetToSendToBackend = createSelector(getViewById, mapSelectors.getMapPreset, syncGroupsSelectors.getAllTargetGroupsForSource, (workspaceView, mapPreset, syncGroupsIds) => {
4219
+ const getViewComponentType = createSelector(getViewById, store => (store === null || store === void 0 ? void 0 : store.componentType) || 'Map', selectorMemoizationOptions);
4220
+ const getViewPresetToSendToBackend = createSelector(getViewById, getViewComponentType, mapSelectors.getMapPreset, syncGroupsSelectors.getAllTargetGroupsForSource, timeSeriesSelectors.getTimeSeriesPreset, (workspaceView, viewComponentType, mapPreset, syncGroupsIds, timeSeriesPreset) => {
4197
4221
  const title = (workspaceView === null || workspaceView === void 0 ? void 0 : workspaceView.title) || translateKeyOutsideComponents('workspace-mappreset-new');
4198
4222
  const scope = (workspaceView === null || workspaceView === void 0 ? void 0 : workspaceView.scope) || 'system';
4199
- return Object.assign(Object.assign({}, emptyMapViewPreset), {
4223
+ const defaultInitialProps = {
4224
+ mapPreset,
4225
+ syncGroupsIds
4226
+ };
4227
+ const initialPropsByComponentType = {
4228
+ Map: defaultInitialProps,
4229
+ TimeSeries: timeSeriesPreset
4230
+ };
4231
+ return Object.assign(Object.assign({}, emptyViewPreset(viewComponentType)), {
4200
4232
  id: workspaceView === null || workspaceView === void 0 ? void 0 : workspaceView.id,
4201
4233
  scope,
4202
4234
  title,
4203
- initialProps: {
4204
- mapPreset,
4205
- syncGroupsIds
4206
- }
4235
+ initialProps: initialPropsByComponentType[viewComponentType] || defaultInitialProps
4207
4236
  });
4208
4237
  }, selectorMemoizationOptions);
4209
4238
 
@@ -4215,6 +4244,7 @@ var selectors$1 = /*#__PURE__*/Object.freeze({
4215
4244
  getSelectedWorkspaceTitle: getSelectedWorkspaceTitle,
4216
4245
  getShouldPreventClose: getShouldPreventClose,
4217
4246
  getViewById: getViewById,
4247
+ getViewComponentType: getViewComponentType,
4218
4248
  getViewIds: getViewIds,
4219
4249
  getViewPresetToSendToBackend: getViewPresetToSendToBackend,
4220
4250
  getViewType: getViewType,
@@ -4240,6 +4270,7 @@ var selectors$1 = /*#__PURE__*/Object.freeze({
4240
4270
  *
4241
4271
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4242
4272
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
4273
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
4243
4274
  * */
4244
4275
  const viewPresetsListAdapter = createEntityAdapter();
4245
4276
  const initialState = viewPresetsListAdapter.getInitialState();
@@ -6988,6 +7019,7 @@ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNa
6988
7019
  *
6989
7020
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
6990
7021
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7022
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
6991
7023
  * */
6992
7024
  const routes = {
6993
7025
  root: '/',
@@ -7220,6 +7252,7 @@ function* workspaceSaga() {
7220
7252
  *
7221
7253
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7222
7254
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7255
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7223
7256
  * */
7224
7257
  var WorkspaceListErrorType;
7225
7258
  (function (WorkspaceListErrorType) {
@@ -7242,6 +7275,7 @@ var WorkspaceListErrorType;
7242
7275
  *
7243
7276
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7244
7277
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7278
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7245
7279
  * */
7246
7280
  const getWorkspaceListStore = store => {
7247
7281
  if (store && store.workspaceList) {
@@ -7563,6 +7597,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
7563
7597
  *
7564
7598
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7565
7599
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7600
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7566
7601
  * */
7567
7602
  const processError = (error, component, errorMessageKey) => {
7568
7603
  const message = isAxiosError$1(error) ? getAxiosErrorMessage(error) : translateKeyOutsideComponents(errorMessageKey);
@@ -7682,17 +7717,17 @@ viewPresetsListener.startListening({
7682
7717
  // new map preset selected
7683
7718
  listenerApi.dispatch(mapStoreActions.setMapPreset({
7684
7719
  mapId: panelId,
7685
- initialProps: emptyMapViewPreset.initialProps
7720
+ initialProps: emptyViewPreset('Map').initialProps
7686
7721
  }));
7687
7722
  // update workspace with new empy view map
7688
7723
  listenerApi.dispatch(workspaceActions.updateWorkspaceView({
7689
- viewPreset: emptyMapViewPreset,
7724
+ viewPreset: emptyViewPreset('Map'),
7690
7725
  mosaicNodeId: panelId
7691
7726
  }));
7692
7727
  listenerApi.dispatch(viewPresetActions.fetchedViewPreset({
7693
7728
  panelId,
7694
7729
  viewPresetId,
7695
- viewPreset: emptyMapViewPreset
7730
+ viewPreset: emptyViewPreset('Map')
7696
7731
  }));
7697
7732
  }
7698
7733
  })
@@ -7763,6 +7798,7 @@ viewPresetsListener.startListening({
7763
7798
  *
7764
7799
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7765
7800
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7801
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7766
7802
  * */
7767
7803
  const workspaceModuleConfig = {
7768
7804
  id: 'workspace-module',
@@ -7792,6 +7828,7 @@ const workspaceModuleConfig = {
7792
7828
  *
7793
7829
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7794
7830
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
7831
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7795
7832
  * */
7796
7833
  const devToolsStateSanitizer = {
7797
7834
  stateSanitizer: state => {
@@ -8241,6 +8278,7 @@ const defaultComponentsLookUp = ({
8241
8278
  *
8242
8279
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8243
8280
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
8281
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
8244
8282
  * */
8245
8283
  const getUniqueId = (existingIds, count = 1) => {
8246
8284
  const newId = `${count}_screen`;
@@ -8269,6 +8307,7 @@ const createBalancedMosaicNode = currentNode => {
8269
8307
  *
8270
8308
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8271
8309
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
8310
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
8272
8311
  * */
8273
8312
  // Used to retrieve the unfiltered, general view preset list.
8274
8313
  // To ensure you retrieve the view preset list specific for your view, use getFilteredViewPresetListForView
@@ -8513,7 +8552,9 @@ const ViewPresetMenuListConnect = ({
8513
8552
  } = useWorkspaceTranslation();
8514
8553
  const viewPresets = useSelector(store => getFilteredViewPresetListForView(store, panelId));
8515
8554
  const activeViewPresetId = useSelector(store => getViewPresetActiveId(store, panelId));
8555
+ const viewComponentType = useSelector(store => getViewComponentType(store, panelId));
8516
8556
  const currentMapPreset = useSelector(store => mapSelectors.getMapPreset(store, panelId));
8557
+ const currentTimeSeriesPreset = useSelector(store => timeSeriesSelectors.getTimeSeriesPreset(store));
8517
8558
  const viewPresetListFilters = useSelector(store => getViewPresetListFiltersForView(store, panelId));
8518
8559
  const lastViewPresetListFilters = usePrevious(viewPresetListFilters);
8519
8560
  const viewPresetListSearchQuery = useSelector(store => getViewPresetListSearchQueryForView(store, panelId));
@@ -8552,6 +8593,19 @@ const ViewPresetMenuListConnect = ({
8552
8593
  filterParams
8553
8594
  }));
8554
8595
  }, [dispatch, panelId, viewPresetListFilters, viewPresetListSearchQuery]);
8596
+ const constructInitialProps = () => {
8597
+ switch (viewComponentType) {
8598
+ case 'TimeSeries':
8599
+ return currentTimeSeriesPreset;
8600
+ case 'Map':
8601
+ return {
8602
+ mapPreset: currentMapPreset,
8603
+ syncGroupsIds: relatedSyncGroupIds
8604
+ };
8605
+ default:
8606
+ return undefined;
8607
+ }
8608
+ };
8555
8609
  const onClickViewPresetOption = (presetId, workspaceAction, preset) => {
8556
8610
  switch (workspaceAction) {
8557
8611
  case WorkspacePresetAction.DUPLICATE:
@@ -8563,10 +8617,7 @@ const ViewPresetMenuListConnect = ({
8563
8617
  panelId,
8564
8618
  formValues: {
8565
8619
  title: preset.title,
8566
- initialProps: {
8567
- mapPreset: currentMapPreset,
8568
- syncGroupsIds: relatedSyncGroupIds
8569
- }
8620
+ initialProps: constructInitialProps()
8570
8621
  }
8571
8622
  });
8572
8623
  break;
@@ -8961,8 +9012,9 @@ const WorkspaceViewTitleConnectNoMemo = ({
8961
9012
  scope
8962
9013
  };
8963
9014
  }, shallowEqual);
8964
- const hasMapPresetChanges = useSelector(store => getViewPresetHasChanges(store, panelId));
8965
- const activeMapPresetId = useSelector(store => getViewPresetActiveId(store, panelId));
9015
+ const viewComponentType = useSelector(store => getViewComponentType(store, panelId));
9016
+ const hasViewPresetChanges = useSelector(store => getViewPresetHasChanges(store, panelId));
9017
+ const activeViewPresetId = useSelector(store => getViewPresetActiveId(store, panelId));
8966
9018
  const relatedSyncGroupIds = useSelector(store => syncGroupsSelectors.getAllTargetGroupsForSource(store, panelId));
8967
9019
  const getPresetTitle = (title, hasChanges, isNew) => {
8968
9020
  if (!hasChanges) {
@@ -8971,71 +9023,75 @@ const WorkspaceViewTitleConnectNoMemo = ({
8971
9023
  const suffix = isNew ? t('workspace-modified-existing') : t('workspace-modified-new');
8972
9024
  return `${title} (${suffix})`;
8973
9025
  };
8974
- const isNewActive = activeMapPresetId === '';
9026
+ const isNewActive = activeViewPresetId === '';
8975
9027
  const title = workspaceView.title || t('workspace-mappreset-new');
8976
9028
  const viewScope = workspaceView.scope;
8977
- const fullTitle = getPresetTitle(title, hasMapPresetChanges, isNewActive);
9029
+ const fullTitle = getPresetTitle(title, hasViewPresetChanges, isNewActive);
8978
9030
  const openViewPresetsDialog = React.useCallback(viewPresetDialogOptions => {
8979
9031
  dispatch(viewPresetActions.openViewPresetDialog({
8980
9032
  viewPresetDialog: viewPresetDialogOptions
8981
9033
  }));
8982
9034
  }, [dispatch]);
9035
+ const constructInitialProps = React.useCallback(() => {
9036
+ switch (viewComponentType) {
9037
+ case 'TimeSeries':
9038
+ return timeSeriesSelectors.getTimeSeriesPreset(store.getState());
9039
+ case 'Map':
9040
+ return {
9041
+ mapPreset: mapSelectors.getMapPreset(store.getState(), panelId),
9042
+ syncGroupsIds: relatedSyncGroupIds
9043
+ };
9044
+ default:
9045
+ return undefined;
9046
+ }
9047
+ }, [panelId, relatedSyncGroupIds, store, viewComponentType]);
8983
9048
  const onSave = React.useCallback(() => {
8984
9049
  dispatch(viewPresetActions.saveViewPreset({
8985
9050
  panelId,
8986
- viewPresetId: activeMapPresetId,
8987
- viewPreset: Object.assign(Object.assign({}, emptyMapViewPreset), {
9051
+ viewPresetId: activeViewPresetId,
9052
+ viewPreset: Object.assign(Object.assign({}, emptyViewPreset(viewComponentType)), {
8988
9053
  title,
8989
- initialProps: {
8990
- mapPreset: mapSelectors.getMapPreset(store.getState(), panelId),
8991
- syncGroupsIds: relatedSyncGroupIds
8992
- }
9054
+ initialProps: constructInitialProps()
8993
9055
  })
8994
9056
  }));
8995
- }, [activeMapPresetId, dispatch, panelId, relatedSyncGroupIds, store, title]);
9057
+ }, [activeViewPresetId, constructInitialProps, dispatch, panelId, title, viewComponentType]);
8996
9058
  const onDelete = React.useCallback(() => {
8997
9059
  openViewPresetsDialog({
8998
9060
  title: t('workspace-mappreset-dialog-title-delete'),
8999
9061
  action: PresetAction.DELETE,
9000
- viewPresetId: activeMapPresetId,
9062
+ viewPresetId: activeViewPresetId,
9001
9063
  panelId,
9002
9064
  formValues: {
9003
9065
  title
9004
9066
  }
9005
9067
  });
9006
- }, [activeMapPresetId, openViewPresetsDialog, panelId, title, t]);
9068
+ }, [activeViewPresetId, openViewPresetsDialog, panelId, title, t]);
9007
9069
  const onSaveAs = React.useCallback(() => {
9008
- const formTitle = activeMapPresetId ? title : '';
9070
+ const formTitle = activeViewPresetId ? title : '';
9009
9071
  openViewPresetsDialog({
9010
9072
  title: t('workspace-mappreset-save-as'),
9011
9073
  action: PresetAction.SAVE_AS,
9012
- viewPresetId: activeMapPresetId,
9074
+ viewPresetId: activeViewPresetId,
9013
9075
  panelId,
9014
9076
  formValues: {
9015
9077
  title: formTitle,
9016
- initialProps: {
9017
- mapPreset: mapSelectors.getMapPreset(store.getState(), panelId),
9018
- syncGroupsIds: relatedSyncGroupIds
9019
- }
9078
+ initialProps: constructInitialProps()
9020
9079
  }
9021
9080
  });
9022
- }, [activeMapPresetId, openViewPresetsDialog, panelId, relatedSyncGroupIds, store, title, t]);
9081
+ }, [activeViewPresetId, constructInitialProps, openViewPresetsDialog, panelId, t, title]);
9023
9082
  const onEdit = React.useCallback(() => {
9024
- const formTitle = activeMapPresetId ? title : '';
9083
+ const formTitle = activeViewPresetId ? title : '';
9025
9084
  openViewPresetsDialog({
9026
9085
  title: t('workspace-mappreset-dialog-title-edit'),
9027
9086
  action: PresetAction.EDIT,
9028
9087
  panelId,
9029
- viewPresetId: activeMapPresetId,
9088
+ viewPresetId: activeViewPresetId,
9030
9089
  formValues: {
9031
9090
  title: formTitle,
9032
- initialProps: {
9033
- mapPreset: mapSelectors.getMapPreset(store.getState(), panelId),
9034
- syncGroupsIds: relatedSyncGroupIds
9035
- }
9091
+ initialProps: constructInitialProps()
9036
9092
  }
9037
9093
  });
9038
- }, [activeMapPresetId, openViewPresetsDialog, panelId, relatedSyncGroupIds, store, title, t]);
9094
+ }, [activeViewPresetId, constructInitialProps, openViewPresetsDialog, panelId, t, title]);
9039
9095
  const toggleViewPresetDialog = React.useCallback(({
9040
9096
  panelId,
9041
9097
  isViewPresetDialogOpen
@@ -9067,7 +9123,7 @@ const WorkspaceViewTitleConnectNoMemo = ({
9067
9123
  })), jsx(WorkspaceOptions, {
9068
9124
  panelId: panelId,
9069
9125
  title: fullTitle,
9070
- hasChanges: hasMapPresetChanges || isNewActive,
9126
+ hasChanges: hasViewPresetChanges || isNewActive,
9071
9127
  handleSave: viewScope === 'user' ? onSave : undefined,
9072
9128
  handleDelete: viewScope === 'user' ? onDelete : undefined,
9073
9129
  handleSaveAs: onSaveAs,
@@ -10049,6 +10105,7 @@ const validateTitle = value => {
10049
10105
  return !value.trim().length ? 'This field is required' : true;
10050
10106
  };
10051
10107
  const MapPresetsForm = ({
10108
+ viewComponentType,
10052
10109
  error,
10053
10110
  onSubmit,
10054
10111
  action,
@@ -10058,7 +10115,7 @@ const MapPresetsForm = ({
10058
10115
  const {
10059
10116
  t
10060
10117
  } = useWorkspaceTranslation();
10061
- const _a = Object.assign(Object.assign({}, emptyMapViewPreset), formValues),
10118
+ const _a = Object.assign(Object.assign({}, emptyViewPreset(viewComponentType)), formValues),
10062
10119
  {
10063
10120
  title
10064
10121
  } = _a,
@@ -10126,6 +10183,7 @@ const MapPresetsFormDialog = ({
10126
10183
  isOpen,
10127
10184
  action,
10128
10185
  viewPresetId,
10186
+ viewComponentType,
10129
10187
  formValues,
10130
10188
  onSuccess,
10131
10189
  onClose,
@@ -10237,6 +10295,7 @@ const MapPresetsFormDialog = ({
10237
10295
  onSubmit: onSubmit,
10238
10296
  isLoading: isLoading,
10239
10297
  content: jsx(MapPresetsForm, {
10298
+ viewComponentType: viewComponentType,
10240
10299
  formValues: formValues,
10241
10300
  error: error,
10242
10301
  onSubmit: onSubmit,
@@ -10256,6 +10315,8 @@ const MapPresetsFormDialogWrapper = _a => {
10256
10315
  const MapPresetsFormDialogConnect = () => {
10257
10316
  const dispatch = useDispatch();
10258
10317
  const dialogOptions = useSelector(store => getDialogOptions(store));
10318
+ const panelId = dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.panelId;
10319
+ const viewComponentType = useSelector(store => getViewComponentType(store, panelId));
10259
10320
  const closeDialog = React__default.useCallback(() => {
10260
10321
  dispatch(viewPresetActions.closeViewPresetDialog());
10261
10322
  }, [dispatch]);
@@ -10264,7 +10325,7 @@ const MapPresetsFormDialogConnect = () => {
10264
10325
  };
10265
10326
  const onSuccess = (action, newViewPresetId, title) => {
10266
10327
  dispatch(viewPresetActions.onSuccessViewPresetAction({
10267
- panelId: dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.panelId,
10328
+ panelId,
10268
10329
  viewPresetId: newViewPresetId,
10269
10330
  action,
10270
10331
  title
@@ -10277,7 +10338,8 @@ const MapPresetsFormDialogConnect = () => {
10277
10338
  return jsx(MapPresetsFormDialogWrapper, Object.assign({
10278
10339
  isOpen: isOpen,
10279
10340
  onClose: onClose,
10280
- onSuccess: onSuccess
10341
+ onSuccess: onSuccess,
10342
+ viewComponentType: viewComponentType
10281
10343
  }, dialogOptions, {
10282
10344
  formValues: dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.formValues
10283
10345
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/workspace",
3
- "version": "9.25.2",
3
+ "version": "9.26.0",
4
4
  "description": "GeoWeb Workspace library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "i18next": "^23.11.5",
37
37
  "react-i18next": "^14.1.2",
38
38
  "@mui/material": "^5.16.0",
39
- "@opengeoweb/webmap-react": "9.25.2"
39
+ "@opengeoweb/webmap-react": "9.26.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "18"
@@ -1,18 +1,16 @@
1
- import { mapTypes } from '@opengeoweb/store';
2
1
  import React from 'react';
3
- import { PresetAction } from '../../store/viewPresets/types';
4
- export interface MapPresetFormValues {
2
+ import { InitialProps } from '@opengeoweb/core';
3
+ import { PresetAction, WorkspaceSupportedComponentTypes } from '../../store/viewPresets/types';
4
+ export interface ViewPresetFormValues {
5
5
  title?: string;
6
- initialProps?: {
7
- mapPreset: mapTypes.MapPreset;
8
- syncGroupsIds?: string[];
9
- };
6
+ initialProps?: InitialProps;
10
7
  }
11
- interface MapPresetsFormProps {
8
+ export interface MapPresetsFormProps {
9
+ viewComponentType: WorkspaceSupportedComponentTypes;
12
10
  error?: string;
13
11
  onSubmit?: () => void;
14
12
  action: PresetAction;
15
- formValues: MapPresetFormValues;
13
+ formValues: ViewPresetFormValues;
16
14
  }
17
15
  declare const MapPresetsForm: React.FC<MapPresetsFormProps>;
18
16
  export default MapPresetsForm;
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
- import { MapPresetFormValues } from './MapPresetsForm';
3
- import { PresetAction } from '../../store/viewPresets/types';
2
+ import { ViewPresetFormValues } from './MapPresetsForm';
3
+ import { PresetAction, WorkspaceSupportedComponentTypes } from '../../store/viewPresets/types';
4
4
  export interface MapPresetsFormDialogProps {
5
5
  isOpen: boolean;
6
6
  title: string;
7
7
  action: PresetAction;
8
8
  viewPresetId: string;
9
- formValues: MapPresetFormValues;
9
+ viewComponentType: WorkspaceSupportedComponentTypes;
10
+ formValues: ViewPresetFormValues;
10
11
  onSuccess: (action: PresetAction, presetId: string, title: string) => void;
11
12
  onClose: () => void;
12
13
  }
@@ -1,12 +1,14 @@
1
1
  import { InitialProps, SupportedComponentTypes } from '@opengeoweb/core';
2
+ import { SupportedComponentTypes as SupportedTimeSeriesComponentTypes } from '@opengeoweb/timeseries';
2
3
  import { EntityState } from '@reduxjs/toolkit';
3
4
  import { FetchViewPresetsListParams, PresetScope, ViewPresetListItem } from '../viewPresetsList/types';
4
5
  import { WorkspaceViewPresetComponentsLookupType } from '../workspace/types';
6
+ export type WorkspaceSupportedComponentTypes = SupportedComponentTypes | SupportedTimeSeriesComponentTypes | WorkspaceViewPresetComponentsLookupType;
5
7
  export interface ViewPreset {
6
8
  id?: string;
7
9
  title: string;
8
10
  keywords: string;
9
- componentType: SupportedComponentTypes | WorkspaceViewPresetComponentsLookupType;
11
+ componentType: WorkspaceSupportedComponentTypes;
10
12
  initialProps?: InitialProps;
11
13
  scope?: PresetScope;
12
14
  }
@@ -1,15 +1,7 @@
1
1
  import { PresetsApi } from '../../utils/api';
2
- import { PresetAction, ViewPresetsListFilter } from './types';
2
+ import { PresetAction, ViewPreset, ViewPresetsListFilter, WorkspaceSupportedComponentTypes } from './types';
3
3
  import { FetchViewPresetsListParams } from '../viewPresetsList/types';
4
4
  export declare const getSnackbarMessage: (action: PresetAction, title: string) => string;
5
5
  export declare const getPresetsApi: () => PresetsApi;
6
- export declare const emptyMapViewPreset: {
7
- componentType: "Map";
8
- keywords: string;
9
- scope: "user";
10
- title: string;
11
- initialProps: {
12
- mapPreset: {};
13
- };
14
- };
6
+ export declare const emptyViewPreset: (componentType?: WorkspaceSupportedComponentTypes | undefined) => ViewPreset;
15
7
  export declare const constructFilterParams: (filters: ViewPresetsListFilter[], searchQuery: string) => FetchViewPresetsListParams;
@@ -1,5 +1,7 @@
1
+ import { InitialProps } from '@opengeoweb/core';
1
2
  import { WorkspaceState } from './types';
2
3
  import { AppStore } from '../types';
4
+ import { WorkspaceSupportedComponentTypes } from '../viewPresets/types';
3
5
  /**
4
6
  * Gets workspace state
5
7
  *
@@ -157,26 +159,25 @@ export declare const getWorkspaceData: ((state: AppStore & import("@opengeoweb/s
157
159
  }> & {
158
160
  clearCache: () => void;
159
161
  };
162
+ export declare const getViewComponentType: ((state: AppStore, viewId: string) => WorkspaceSupportedComponentTypes) & import("reselect").OutputSelectorFields<(args_0: import("./types").WorkspaceViewType | undefined) => WorkspaceSupportedComponentTypes, {
163
+ clearCache: () => void;
164
+ }> & {
165
+ clearCache: () => void;
166
+ };
160
167
  export declare const getViewPresetToSendToBackend: ((state: any, viewId: any) => {
161
168
  id: string | undefined;
162
169
  scope: import("./types").PresetScope;
163
170
  title: string;
164
- initialProps: {
165
- mapPreset: import("@opengeoweb/store").MapPreset;
166
- syncGroupsIds: string[];
167
- };
168
- componentType: "Map";
171
+ initialProps: InitialProps;
169
172
  keywords: string;
170
- }) & import("reselect").OutputSelectorFields<(args_0: import("./types").WorkspaceViewType | undefined, args_1: import("@opengeoweb/store").MapPreset, args_2: string[]) => {
173
+ componentType: WorkspaceSupportedComponentTypes;
174
+ }) & import("reselect").OutputSelectorFields<(args_0: import("./types").WorkspaceViewType | undefined, args_1: WorkspaceSupportedComponentTypes, args_2: import("@opengeoweb/store").MapPreset, args_3: string[], args_4: import("dist/libs/timeseries/src/lib/store/types").TimeSeriesPreset | undefined) => {
171
175
  id: string | undefined;
172
176
  scope: import("./types").PresetScope;
173
177
  title: string;
174
- initialProps: {
175
- mapPreset: import("@opengeoweb/store").MapPreset;
176
- syncGroupsIds: string[];
177
- };
178
- componentType: "Map";
178
+ initialProps: InitialProps;
179
179
  keywords: string;
180
+ componentType: WorkspaceSupportedComponentTypes;
180
181
  }, {
181
182
  clearCache: () => void;
182
183
  }> & {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { MapPreset, syncGroupsTypes } from '@opengeoweb/store';
3
3
  import { MosaicNode } from 'react-mosaic-component';
4
- type InitialPropsWorkspaceViewType = Record<string, unknown>;
4
+ export type InitialPropsWorkspaceViewType = Record<string, unknown>;
5
5
  export type WorkspaceViewPresetComponentsLookupType = 'ViewError' | 'ViewLoading';
6
6
  export interface WorkspaceViewType {
7
7
  id?: string;
@@ -142,4 +142,3 @@ export interface WorkspaceErrorWorkspacePayload {
142
142
  workspaceId: string;
143
143
  error: WorkspaceError;
144
144
  }
145
- export {};