Skip to content

Commit

Permalink
#1965: Align the map layer settings to MapStore (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored Feb 28, 2025
1 parent 05f649f commit b093ff3
Show file tree
Hide file tree
Showing 36 changed files with 28 additions and 1,664 deletions.
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/MapStore2
Submodule MapStore2 updated 384 files
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export default createPlugin('LayerDetailViewer', {
TOC: {
target: 'toolbar',
name: 'LayerDetailViewerButton',
Component: ConnectedButton
Component: ConnectedButton,
position: 12
}
},
reducers: {
Expand Down
194 changes: 0 additions & 194 deletions geonode_mapstore_client/client/js/plugins/LayerSettings.jsx

This file was deleted.

79 changes: 6 additions & 73 deletions geonode_mapstore_client/client/js/plugins/VisualStyleEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { createPlugin } from '@mapstore/framework/utils/PluginsUtils';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { Glyphicon } from 'react-bootstrap';

import { StyleCodeEditor } from '@mapstore/framework/plugins/styleeditor/index';
import styleeditor from '@mapstore/framework/reducers/styleeditor';
import styleeditorEpics from '@mapstore/framework/epics/styleeditor';
import visualStyleEditorEpics from '@js/epics/visualstyleeditor';
import { setControlProperty } from '@mapstore/framework/actions/controls';
import {
updateStatus,
Expand All @@ -24,10 +24,6 @@ import {
editStyleCode,
updateEditorMetadata
} from '@mapstore/framework/actions/styleeditor';
import {
requestDatasetAvailableStyles
} from '@js/actions/visualstyleeditor';

import { updateNode, updateSettingsParams } from '@mapstore/framework/actions/layers';
import {
getUpdatedLayer,
Expand All @@ -42,17 +38,18 @@ import {
selectedStyleSelector
} from '@mapstore/framework/selectors/styleeditor';
import Message from '@mapstore/framework/components/I18N/Message';
import GNButton from '@js/components/Button';
import Portal from '@mapstore/framework/components/misc/Portal';
import ResizableModal from '@mapstore/framework/components/misc/ResizableModal';
import StylesAPI from '@mapstore/framework/api/geoserver/Styles';
import { getResourcePerms, isNewResource, getViewedResourceType } from '@js/selectors/resource';
import { mapLayoutValuesSelector } from '@mapstore/framework/selectors/maplayout';
import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip';
import { getSelectedLayer, layersSelector } from '@mapstore/framework/selectors/layers';

import GNButton from '@js/components/Button';
import visualStyleEditorEpics from '@js/epics/visualstyleeditor';
import { getViewedResourceType } from '@js/selectors/resource';
import useLocalStorage from '@js/hooks/useLocalStorage';
import TemplateSelector from '@js/plugins/visualstyleeditor/TemplateSelector';
import { isDefaultDatasetSubtype, SOURCE_TYPES } from '@js/utils/ResourceUtils';

const Button = tooltip(GNButton);

Expand Down Expand Up @@ -303,73 +300,9 @@ const VisualStyleEditorPlugin = connect(
}
)(VisualStyleEditor);

function StyleEditorTocButton({
layer,
status,
onClick = () => {},
changeResource,
isNew,
btnProps = {},
hide,
selectedStyle,
statusTypes
}) {
const mapLayer = layer?.extendedParams?.mapLayer;
if (hide
|| status !== statusTypes?.LAYER
|| !mapLayer?.dataset
|| mapLayer?.dataset?.sourcetype === SOURCE_TYPES.REMOTE
|| !changeResource
|| isNew
|| !isDefaultDatasetSubtype(mapLayer?.dataset?.subtype)) {
return null;
}

function handleClick(event) {
event.stopPropagation();
event.preventDefault();
onClick(layer, { style: selectedStyle });
}
function handleMouseDown(event) {
event.stopPropagation();
event.preventDefault();
}

return (
<Button
variant="primary"
className="square-button-md"
{...btnProps}
onClick={handleClick}
onMouseDown={handleMouseDown}
tooltipId={<Message msgId={`gnviewer.editLayerStyle`} />}
>
<Glyphicon glyph="dropper"/>
</Button>
);
}

const ConnectedStyleEditorTocButton = connect(createSelector([
getUpdatedLayer,
getResourcePerms,
isNewResource
], (layer, perms, newMap) => ({
layer,
changeResource: !!perms?.includes('change_resourcebase'),
isNew: newMap
})), {
onClick: requestDatasetAvailableStyles
})(StyleEditorTocButton);

export default createPlugin('VisualStyleEditor', {
component: VisualStyleEditorPlugin,
containers: {
TOC: {
target: 'toolbar',
Component: ConnectedStyleEditorTocButton,
position: 100
}
},
containers: {},
reducers: {
styleeditor
},
Expand Down
Loading

0 comments on commit b093ff3

Please sign in to comment.