Skip to content

Commit

Permalink
#9567: handle adding flag into config file to show/hide zoom icon for…
Browse files Browse the repository at this point in the history
… tblWidget
  • Loading branch information
mahmoudadel54 committed Oct 25, 2023
1 parent 73d51f8 commit d726313
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('widgets tableWidget enhancer', () => {
}}/></Provider>, document.getElementById("container"));
});

it('tableWidget with gridTools including zoom icon for dashboard viewer', (done) => {
it('tableWidget with gridTools including zoom icon for dashboard viewer [enable zoom in config]', (done) => {
const Sink = tableWidget(createSink( props => {
expect(props).toExist();
expect(props.gridTools.length).toEqual(1);
Expand All @@ -57,7 +57,9 @@ describe('widgets tableWidget enhancer', () => {
);
done();
}));
ReactDOM.render( <Provider store={store}><Sink id="123456" mapSync={"true"} widgetType={"table"} isDashboardOpened={"true"} updateProperty={(id, path, value) => {
ReactDOM.render( <Provider store={store}><Sink enableZoomTblWidget={{
dashboard: true
}} id="123456" mapSync={"true"} widgetType={"table"} isDashboardOpened={"true"} updateProperty={(id, path, value) => {
expect(path).toBe("dependencies.extentObj");
expect(id).toBe("123456");
expect(value).toEqual({
Expand All @@ -68,7 +70,26 @@ describe('widgets tableWidget enhancer', () => {
expect(container).toExist();

});
it('tableWidget with gridTools including zoom icon for mapViewer', (done) => {
it('tableWidget with gridTools including zoom icon for dashboard viewer [not enable zoom in config]', (done) => {
const Sink = tableWidget(createSink( props => {
expect(props).toExist();
expect(props.gridTools.length).toEqual(0);
done();
}));
ReactDOM.render( <Provider store={store}><Sink enableZoomTblWidget={{
dashboard: false
}} id="123456" mapSync={"true"} widgetType={"table"} isDashboardOpened={"true"} updateProperty={(id, path, value) => {
expect(path).toBe("dependencies.extentObj");
expect(id).toBe("123456");
expect(value).toEqual({
bbox: [-10, 0, 0, -10]
}, {}, "", { crs: "EPSG:4326", maxZoom: null });
}}/></Provider>, document.getElementById("container"));
const container = document.getElementById('container');
expect(container).toExist();

});
it('tableWidget with gridTools including zoom icon for mapViewer [enable zoom in config]', (done) => {
const Sink = tableWidget(createSink( props => {
expect(props).toExist();
expect(props.gridTools.length).toEqual(1);
Expand All @@ -79,7 +100,22 @@ describe('widgets tableWidget enhancer', () => {
);
done();
}));
ReactDOM.render( <Provider store={store}><Sink id="123456" widgetType={"table"} /></Provider>, document.getElementById("container"));
ReactDOM.render( <Provider store={store}><Sink enableZoomTblWidget={{
mapViewer: true
}} id="123456" widgetType={"table"} /></Provider>, document.getElementById("container"));
const container = document.getElementById('container');
expect(container).toExist();

});
it('tableWidget with gridTools including zoom icon for mapViewer [not enable zoom in config]', (done) => {
const Sink = tableWidget(createSink( props => {
expect(props).toExist();
expect(props.gridTools.length).toEqual(0);
done();
}));
ReactDOM.render( <Provider store={store}><Sink enableZoomTblWidget={{
mapViewer: false
}} id="123456" widgetType={"table"} /></Provider>, document.getElementById("container"));
const container = document.getElementById('container');
expect(container).toExist();

Expand Down
5 changes: 3 additions & 2 deletions web/client/components/widgets/enhancers/tableWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ const withSorting = () => withPropsOnChange(["gridEvents"], ({ gridEvents = {},
*/
export default compose(
compose(connect(null, (dispatch, ownProps)=>{
let isTblDashboard = ownProps?.mapSync && ownProps?.widgetType === 'table' && ownProps?.isDashboardOpened;
let isTblWidgetInMapViewer = ownProps?.widgetType && !isTblDashboard;
let enableZoomTblWidget = ownProps?.enableZoomTblWidget;
let isTblDashboard = enableZoomTblWidget?.dashboard && ownProps?.mapSync && ownProps?.widgetType === 'table' && ownProps?.isDashboardOpened;
let isTblWidgetInMapViewer = ownProps?.widgetType && !isTblDashboard && enableZoomTblWidget?.mapViewer;
let isTblSyncWithMap = ownProps?.mapSync;
return {
gridTools: (isTblSyncWithMap && isTblDashboard) || (isTblWidgetInMapViewer) ? gridTools.map((t) => ({
Expand Down
14 changes: 12 additions & 2 deletions web/client/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,12 @@
"declineUrl" : "http://www.google.com"
}
},
"OmniBar", "Login", "Save", "SaveAs", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", "Widgets",
"OmniBar", "Login", "Save", "SaveAs", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", {
"name": "Widgets",
"cfg": {
"enableZoomInTblWidget": true
}
},
"WidgetsTray",
{
"name": "Timeline",
Expand Down Expand Up @@ -742,7 +747,12 @@
],
"dashboard": [
"BurgerMenu",
"Dashboard",
{
"name": "Dashboard",
"cfg": {
"enableZoomInTblWidget": false
}
},
"Notifications",
"Login",
{
Expand Down
9 changes: 6 additions & 3 deletions web/client/plugins/Widgets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
getMaximizedState,
getVisibleFloatingWidgets,
isTrayEnabled,
getTblWidgetZoomLoader
getTblWidgetZoomLoader,
getFlagOfShowingTblWidgetZoom
} from '../selectors/widgets';
import {
changeLayout,
Expand Down Expand Up @@ -58,7 +59,8 @@ compose(
state => state.browser && state.browser.mobile,
getFloatingWidgets,
getTblWidgetZoomLoader,
(id, widgets, layouts, maximized, dependencies, mapLayout, isMobileAgent, dropdownWidgets, recordZoomLoading) => ({
getFlagOfShowingTblWidgetZoom,
(id, widgets, layouts, maximized, dependencies, mapLayout, isMobileAgent, dropdownWidgets, recordZoomLoading, enableZoomTblWidget) => ({
id,
widgets,
layouts,
Expand All @@ -67,7 +69,8 @@ compose(
mapLayout,
isMobileAgent,
dropdownWidgets,
recordZoomLoading
recordZoomLoading,
enableZoomTblWidget
})
), {
editWidget,
Expand Down
12 changes: 12 additions & 0 deletions web/client/selectors/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,15 @@ export const getTblWidgetZoomLoader = state => {
let tableWidgets = (getFloatingWidgets(state) || []).filter(({ widgetType } = {}) => widgetType === "table");
return tableWidgets?.find(t=>t.dependencies?.zoomLoader) ? true : false;
};

export const getFlagOfShowingTblWidgetZoom = state => {
let widgetPluginMapViewer = state?.localConfig?.plugins?.desktop?.find(pl=>pl.name === "Widgets");
let flagShownZoomInTblWidgetMapViewer = widgetPluginMapViewer?.cfg?.enableZoomInTblWidget || false;

let dashboardPluginDashboardViewer = state?.localConfig?.plugins?.dashboard?.find(pl=>pl.name === "Dashboard");
let flagShownZoomInTblWidgetDashboardViewer = dashboardPluginDashboardViewer?.cfg?.enableZoomInTblWidget || false;
return {
mapViewer: flagShownZoomInTblWidgetMapViewer,
dashboard: flagShownZoomInTblWidgetDashboardViewer
};
};

0 comments on commit d726313

Please sign in to comment.