Skip to content

Commit

Permalink
Merge pull request #2753 from DenverCoder544/publisher_themeprovider_…
Browse files Browse the repository at this point in the history
…to_panels

Publisher themeprovider to panels
  • Loading branch information
ZakarFin authored Nov 28, 2024
2 parents 1e1025e + 763b2c5 commit 693a200
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 48 deletions.
70 changes: 36 additions & 34 deletions bundles/framework/publisher2/view/MapLayers/MapLayers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const LayerTitle = styled('span')`
const LayerContainer = styled('div')`
display: flex;
flex-direction: column;
margin-top: 20px;
`;

export const MapLayers = ({ state, controller }) => {
Expand All @@ -46,49 +45,52 @@ export const MapLayers = ({ state, controller }) => {
<PublisherToolsList state={state} controller={controller} />
</Card>
{layerListPluginEnabled && (
<Card size='small' title={<Message messageKey='BasicView.mapLayers.baseLayers' />}>
<LayerContainer>
{baseLayers.map((layer) => {
const disabled = !layer.isVisible();
return (
<LayerBox key={layer.getId()} disabled={disabled}>
<LayerTitle>{layer.getName()}</LayerTitle>
{!disabled && (
<IconButton
icon={<DownCircleOutlined />}
onClick={() => controller.removeBaseLayer(layer)}
/>
)}
</LayerBox>
)
})}
</LayerContainer>
{layerListPluginEnabled && baseLayers?.length < 1 && (
<Message messageKey='BasicView.mapLayers.noBaseLayers' />
)}
</Card>
)}
<Card size='small' title={<Message messageKey='BasicView.mapLayers.otherLayers' />}>
<LayerContainer>
<h3><Message messageKey='BasicView.mapLayers.baseLayers' /></h3>
{baseLayers.map((layer) => {
<div className='ant-card-head-title'></div>
{layers.map((layer) => {
const disabled = !layer.isVisible();
return (
<LayerBox key={layer.getId()} disabled={disabled}>
<LayerTitle>{layer.getName()}</LayerTitle>
{!disabled && (
<IconButton
icon={<DownCircleOutlined />}
onClick={() => controller.removeBaseLayer(layer)}
/>
{!disabled && layerListPluginEnabled && (
<Tooltip getPopupContainer={(triggerNode) => triggerNode.parentElement} title={<Message messageKey='BasicView.maptools.layerselection.selectAsBaselayer' />}>
<IconButton
icon={<UpCircleOutlined />}
onClick={() => controller.addBaseLayer(layer)}
/>
</Tooltip>
)}
</LayerBox>
)
})}
</LayerContainer>
)}
{layerListPluginEnabled && baseLayers?.length < 1 && (
<Message messageKey='BasicView.mapLayers.noBaseLayers' />
)}
<LayerContainer>
<h3><Message messageKey='BasicView.mapLayers.otherLayers' /></h3>
{layers.map((layer) => {
const disabled = !layer.isVisible();
return (
<LayerBox key={layer.getId()} disabled={disabled}>
<LayerTitle>{layer.getName()}</LayerTitle>
{!disabled && layerListPluginEnabled && (
<Tooltip getPopupContainer={(triggerNode) => triggerNode.parentElement} title={<Message messageKey='BasicView.maptools.layerselection.selectAsBaselayer' />}>
<IconButton
icon={<UpCircleOutlined />}
onClick={() => controller.addBaseLayer(layer)}
/>
</Tooltip>
)}
</LayerBox>
)
})}
</LayerContainer>
{layers?.length < 1 && (
<Message messageKey='BasicView.mapLayers.noLayers' />
)}
{layers?.length < 1 && (
<Message messageKey='BasicView.mapLayers.noLayers' />
)}
</Card>
<ButtonContainer>
<Button onClick={() => controller.openSelectedLayerList()}>
<Message messageKey='BasicView.mapLayers.layersDisplay' />
Expand Down
16 changes: 9 additions & 7 deletions bundles/framework/publisher2/view/PanelMapLayers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { LocaleProvider } from 'oskari-ui/util';
import { ThemeProvider, LocaleProvider } from 'oskari-ui/util';
import { MapLayers } from './MapLayers/MapLayers';
import ReactDOM from 'react-dom';
import { MapLayersHandler } from '../handler/MapLayersHandler';
Expand Down Expand Up @@ -189,12 +189,14 @@ Oskari.clazz.define('Oskari.mapframework.bundle.publisher2.view.PanelMapLayers',
const contentPanel = this.panel.getContainer();

ReactDOM.render(
<LocaleProvider value={{ bundleKey: 'Publisher2' }}>
<MapLayers
state={this.handler.getState()}
controller={this.handler.getController()}
/>
</LocaleProvider>,
<ThemeProvider>
<LocaleProvider value={{ bundleKey: 'Publisher2' }}>
<MapLayers
state={this.handler.getState()}
controller={this.handler.getController()}
/>
</LocaleProvider>
</ThemeProvider>,
contentPanel[0]
);
},
Expand Down
16 changes: 9 additions & 7 deletions bundles/framework/publisher2/view/PanelRpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { ToolPanelHandler } from '../handler/ToolPanelHandler';
import { PublisherToolsList } from './form/PublisherToolsList';
import { LocaleProvider } from 'oskari-ui/util';
import { ThemeProvider, LocaleProvider } from 'oskari-ui/util';

/**
* @class Oskari.mapframework.bundle.publisher.view.PanelRpc
Expand Down Expand Up @@ -100,12 +100,14 @@ Oskari.clazz.define('Oskari.mapframework.bundle.publisher2.view.PanelRpc',
}
const contentPanel = this.panel.getContainer();
ReactDOM.render(
<LocaleProvider value={{ bundleKey: 'Publisher2' }}>
<PublisherToolsList
state={this.handler.getState()}
controller={this.handler.getController()}
/>
</LocaleProvider>,
<ThemeProvider>
<LocaleProvider value={{ bundleKey: 'Publisher2' }}>
<PublisherToolsList
state={this.handler.getState()}
controller={this.handler.getController()}
/>
</LocaleProvider>
</ThemeProvider>,
contentPanel[0]
);
}
Expand Down

0 comments on commit 693a200

Please sign in to comment.