@@ -11,10 +11,10 @@ import { createPlugin } from '@mapstore/framework/utils/PluginsUtils';
1111import { connect } from 'react-redux' ;
1212import { createSelector } from 'reselect' ;
1313import { Glyphicon } from 'react-bootstrap' ;
14+
1415import { StyleCodeEditor } from '@mapstore/framework/plugins/styleeditor/index' ;
1516import styleeditor from '@mapstore/framework/reducers/styleeditor' ;
1617import styleeditorEpics from '@mapstore/framework/epics/styleeditor' ;
17- import visualStyleEditorEpics from '@js/epics/visualstyleeditor' ;
1818import { setControlProperty } from '@mapstore/framework/actions/controls' ;
1919import {
2020 updateStatus ,
@@ -24,10 +24,6 @@ import {
2424 editStyleCode ,
2525 updateEditorMetadata
2626} from '@mapstore/framework/actions/styleeditor' ;
27- import {
28- requestDatasetAvailableStyles
29- } from '@js/actions/visualstyleeditor' ;
30-
3127import { updateNode , updateSettingsParams } from '@mapstore/framework/actions/layers' ;
3228import {
3329 getUpdatedLayer ,
@@ -42,17 +38,18 @@ import {
4238 selectedStyleSelector
4339} from '@mapstore/framework/selectors/styleeditor' ;
4440import Message from '@mapstore/framework/components/I18N/Message' ;
45- import GNButton from '@js/components/Button' ;
4641import Portal from '@mapstore/framework/components/misc/Portal' ;
4742import ResizableModal from '@mapstore/framework/components/misc/ResizableModal' ;
4843import StylesAPI from '@mapstore/framework/api/geoserver/Styles' ;
49- import { getResourcePerms , isNewResource , getViewedResourceType } from '@js/selectors/resource' ;
5044import { mapLayoutValuesSelector } from '@mapstore/framework/selectors/maplayout' ;
5145import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip' ;
5246import { getSelectedLayer , layersSelector } from '@mapstore/framework/selectors/layers' ;
47+
48+ import GNButton from '@js/components/Button' ;
49+ import visualStyleEditorEpics from '@js/epics/visualstyleeditor' ;
50+ import { getViewedResourceType } from '@js/selectors/resource' ;
5351import useLocalStorage from '@js/hooks/useLocalStorage' ;
5452import TemplateSelector from '@js/plugins/visualstyleeditor/TemplateSelector' ;
55- import { isDefaultDatasetSubtype , SOURCE_TYPES } from '@js/utils/ResourceUtils' ;
5653
5754const Button = tooltip ( GNButton ) ;
5855
@@ -303,73 +300,9 @@ const VisualStyleEditorPlugin = connect(
303300 }
304301) ( VisualStyleEditor ) ;
305302
306- function StyleEditorTocButton ( {
307- layer,
308- status,
309- onClick = ( ) => { } ,
310- changeResource,
311- isNew,
312- btnProps = { } ,
313- hide,
314- selectedStyle,
315- statusTypes
316- } ) {
317- const mapLayer = layer ?. extendedParams ?. mapLayer ;
318- if ( hide
319- || status !== statusTypes ?. LAYER
320- || ! mapLayer ?. dataset
321- || mapLayer ?. dataset ?. sourcetype === SOURCE_TYPES . REMOTE
322- || ! changeResource
323- || isNew
324- || ! isDefaultDatasetSubtype ( mapLayer ?. dataset ?. subtype ) ) {
325- return null ;
326- }
327-
328- function handleClick ( event ) {
329- event . stopPropagation ( ) ;
330- event . preventDefault ( ) ;
331- onClick ( layer , { style : selectedStyle } ) ;
332- }
333- function handleMouseDown ( event ) {
334- event . stopPropagation ( ) ;
335- event . preventDefault ( ) ;
336- }
337-
338- return (
339- < Button
340- variant = "primary"
341- className = "square-button-md"
342- { ...btnProps }
343- onClick = { handleClick }
344- onMouseDown = { handleMouseDown }
345- tooltipId = { < Message msgId = { `gnviewer.editLayerStyle` } /> }
346- >
347- < Glyphicon glyph = "dropper" />
348- </ Button >
349- ) ;
350- }
351-
352- const ConnectedStyleEditorTocButton = connect ( createSelector ( [
353- getUpdatedLayer ,
354- getResourcePerms ,
355- isNewResource
356- ] , ( layer , perms , newMap ) => ( {
357- layer,
358- changeResource : ! ! perms ?. includes ( 'change_resourcebase' ) ,
359- isNew : newMap
360- } ) ) , {
361- onClick : requestDatasetAvailableStyles
362- } ) ( StyleEditorTocButton ) ;
363-
364303export default createPlugin ( 'VisualStyleEditor' , {
365304 component : VisualStyleEditorPlugin ,
366- containers : {
367- TOC : {
368- target : 'toolbar' ,
369- Component : ConnectedStyleEditorTocButton ,
370- position : 100
371- }
372- } ,
305+ containers : { } ,
373306 reducers : {
374307 styleeditor
375308 } ,
0 commit comments