Skip to content

Commit

Permalink
Merge tag '4.3.1' into thuenen_4.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ridoo committed Aug 20, 2024
2 parents b9d9a40 + d6f9c5d commit 17f8d5b
Show file tree
Hide file tree
Showing 33 changed files with 651 additions and 180 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This is a basic workflow to help you get started with Actions

name: GeoNode Client CI 4.3.x (build)

concurrency:
group: "client_build"
cancel-in-progress: true
# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the 4.3.x branch
push:
branches: [ 4.3.x ]
paths:
- "VERSION"
- "geonode_mapstore_client/client/**"
- "!geonode_mapstore_client/client/version.txt"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_and_commit:
env:
working-directory: ./geonode_mapstore_client/client
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive

###########
# SET UP
#########
- name: "Setting up npm"
uses: actions/setup-node@v4
with:
node-version: 20

############
# CACHING
##########
- name: "Cache node modules"
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
###############
# NPM BUILD
#############
- name: "Run npm install"
run: npm install
working-directory: ${{env.working-directory}}

- name: "Run npm compile"
run: npm run compile
working-directory: ${{env.working-directory}}

###############
# COMMIT
#############
- name: "Stage files"
run: git add --all

- name: "Generate temp GitHub token"
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.TOKEN_APP_ID }}
private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }}

- name: "Create Pull Request"
uses: peter-evans/create-pull-request@v3
with:
token: ${{ steps.generate-token.outputs.token }}
base: "4.3.x"
title: "new client build"
body: "Automated client build from GeoNode Client CI"
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: GeoNode Client CI 4.3.x (tests)

# Controls when the workflow will run
on:
# Triggers the workflow pull request events but only for the 4.3.x branch
pull_request:
branches: [ 4.3.x ]
paths:
- "geonode_mapstore_client/client/**"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test-front-end:
env:
working-directory: ./geonode_mapstore_client/client
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive

- name: "Setting up npm"
uses: actions/setup-node@v4
with:
node-version: 20

############
# CACHING
##########
- name: "Cache node modules"
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
###############
# NPM CHECKS
#############
- name: "Run npm install"
run: npm install
working-directory: ${{env.working-directory}}

- name: "Run ESlint"
run: npm run lint
working-directory: ${{env.working-directory}}

- name: "Run Unit Tests"
run: npm test
working-directory: ${{env.working-directory}}

8 changes: 4 additions & 4 deletions .github/workflows/thuenen-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive

###########
# SET UP
#########
- name: "Setting up npm"
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: 20

############
# CACHING
##########
- name: "Cache node modules"
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/thuenen-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive

- name: "Setting up npm"
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: 20

############
# CACHING
############
- name: "Cache node modules"
uses: actions/cache@v1
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.0
4.3.1
13 changes: 13 additions & 0 deletions geonode_mapstore_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ def run_setup_hooks(*args, **kwargs):
"pnts",
)

GEONODE_CATALOGUE_SERVICE = getattr(settings, "GEONODE_CATALOGUE_SERVICE", None)
MAPSTORE_DASHBOARD_CATALOGUE_SERVICES = {}
MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE = ""

if GEONODE_CATALOGUE_SERVICE:
MAPSTORE_DASHBOARD_CATALOGUE_SERVICES[list(list(GEONODE_CATALOGUE_SERVICE.keys()))[0]] = GEONODE_CATALOGUE_SERVICE[
list(list(GEONODE_CATALOGUE_SERVICE.keys()))[0]
] # noqa
MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE = list(list(GEONODE_CATALOGUE_SERVICE.keys()))[0]

setattr(settings, "MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE", MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE)
setattr(settings, "MAPSTORE_DASHBOARD_CATALOGUE_SERVICES", MAPSTORE_DASHBOARD_CATALOGUE_SERVICES)


def connect_geoserver_style_visual_mode_signal():
from geonode.geoserver.signals import geoserver_automatic_default_style_set
Expand Down
2 changes: 2 additions & 0 deletions geonode_mapstore_client/client/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# add legacy peer dependency flag on npm install
legacy-peer-deps=true
# this is needed for node greater then 16
node-options=--openssl-legacy-provider
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import { testEpic } from '@mapstore/framework/epics/__tests__/epicTestUtils';
import {
gnViewerSetNewResourceThumbnail,
closeInfoPanelOnMapClick,
closeDatasetCatalogPanel
closeDatasetCatalogPanel,
gnZoomToFitBounds
} from '@js/epics/gnresource';
import {
setResourceThumbnail,
UPDATE_RESOURCE_PROPERTIES,
UPDATE_SINGLE_RESOURCE
} from '@js/actions/gnresource';
import { clickOnMap } from '@mapstore/framework/actions/map';
import { SET_CONTROL_PROPERTY } from '@mapstore/framework/actions/controls';
import { clickOnMap, changeMapView, ZOOM_TO_EXTENT } from '@mapstore/framework/actions/map';
import { SET_CONTROL_PROPERTY, setControlProperty } from '@mapstore/framework/actions/controls';
import {
SHOW_NOTIFICATION
} from '@mapstore/framework/actions/notifications';
Expand Down Expand Up @@ -174,4 +175,25 @@ describe('gnresource epics', () => {
);

});

it('should zoom to extent with the fitBounds control', (done) => {
const NUM_ACTIONS = 2;
const testState = {};
testEpic(gnZoomToFitBounds,
NUM_ACTIONS,
[setControlProperty('fitBounds', 'geometry', [-180, -90, 180, 90]), changeMapView()],
(actions) => {
try {
expect(actions.length).toBe(2);
expect(actions[0].type).toBe(ZOOM_TO_EXTENT);
expect(actions[1].type).toBe(SET_CONTROL_PROPERTY);
} catch (e) {
done(e);
}
done();
},
testState
);

});
});
48 changes: 40 additions & 8 deletions geonode_mapstore_client/client/js/epics/gnresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ import {
import {
setControlProperty,
resetControls,
SET_CONTROL_PROPERTY,
setControlProperties
SET_CONTROL_PROPERTY
} from '@mapstore/framework/actions/controls';
import {
resourceToLayerConfig,
Expand All @@ -93,7 +92,7 @@ import { updateAdditionalLayer } from '@mapstore/framework/actions/additionallay
import { STYLE_OWNER_NAME } from '@mapstore/framework/utils/StyleEditorUtils';
import { styleServiceSelector } from '@mapstore/framework/selectors/styleeditor';
import { updateStyleService } from '@mapstore/framework/api/StyleEditor';
import { CLICK_ON_MAP, resizeMap } from '@mapstore/framework/actions/map';
import { CLICK_ON_MAP, resizeMap, CHANGE_MAP_VIEW, zoomToExtent } from '@mapstore/framework/actions/map';
import { purgeMapInfoResults, closeIdentify, NEW_MAPINFO_REQUEST } from '@mapstore/framework/actions/mapInfo';
import { saveError } from '@js/actions/gnsave';
import {
Expand All @@ -115,6 +114,8 @@ import { parseDevHostname } from '@js/utils/APIUtils';
import { ProcessTypes } from '@js/utils/ResourceServiceUtils';
import { catalogClose } from '@mapstore/framework/actions/catalog';

const FIT_BOUNDS_CONTROL = 'fitBounds';

const resourceTypes = {
[ResourceTypes.DATASET]: {
resourceObservable: (pk, options) => {
Expand Down Expand Up @@ -174,7 +175,7 @@ const resourceTypes = {
}
}),
...((extent && !currentMap)
? [ setControlProperty('fitBounds', 'geometry', extent) ]
? [ setControlProperty(FIT_BOUNDS_CONTROL, 'geometry', extent) ]
: []),
setControlProperty('toolbar', 'expanded', false),
setControlProperty('rightOverlay', 'enabled', 'DetailViewer'),
Expand Down Expand Up @@ -261,8 +262,7 @@ const resourceTypes = {
}
: mapConfig),
...(extent
// Add duration to allow map config to be properly updated with zoom on fitBounds action
? [ setControlProperties('fitBounds', 'geometry', extent, "duration", 400) ]
? [ setControlProperty(FIT_BOUNDS_CONTROL, 'geometry', extent) ]
: []),
setControlProperty('toolbar', 'expanded', false)
);
Expand Down Expand Up @@ -413,7 +413,7 @@ const getResetActions = (isSameResource) => [
resetControls(),
...(!isSameResource ? [ resetResourceState() ] : []),
setControlProperty('rightOverlay', 'enabled', false),
setControlProperty('fitBounds', 'geometry', null)
setControlProperty(FIT_BOUNDS_CONTROL, 'geometry', null)
];

export const gnViewerRequestNewResourceConfig = (action$, store) =>
Expand Down Expand Up @@ -648,12 +648,44 @@ export const gnManageLinkedResource = (action$, store) =>
))
);
});

const MAX_EXTENT_WEB_MERCATOR = [-180, -85, 180, 85];

function validateGeometry(extent, projection) {
if (extent && ['EPSG:900913', 'EPSG:3857'].includes(projection)) {
const [minx, miny, maxx, maxy] = extent;
const [eMinx, eMiny, eMaxx, eMaxy] = MAX_EXTENT_WEB_MERCATOR;
return [
minx < eMinx ? eMinx : minx,
(miny < eMiny || miny > eMaxy) ? eMiny : miny,
maxx > eMaxx ? eMaxx : maxx,
(maxy > eMaxy || maxy < eMiny) ? eMaxy : maxy
];
}
return extent;
}
export const gnZoomToFitBounds = (action$) =>
action$.ofType(SET_CONTROL_PROPERTY)
.filter(action => action.control === FIT_BOUNDS_CONTROL && !!action.value)
.switchMap((action) =>
action$.ofType(CHANGE_MAP_VIEW)
.take(1)
.switchMap(() => {
const extent = validateGeometry(action.value);
return Observable.of(
zoomToExtent(extent, 'EPSG:4326'),
setControlProperty(FIT_BOUNDS_CONTROL, 'geometry', null)
);
})
);

export default {
gnViewerRequestNewResourceConfig,
gnViewerRequestResourceConfig,
gnViewerSetNewResourceThumbnail,
closeInfoPanelOnMapClick,
closeOpenPanels,
closeDatasetCatalogPanel,
gnManageLinkedResource
gnManageLinkedResource,
gnZoomToFitBounds
};
Loading

0 comments on commit 17f8d5b

Please sign in to comment.