Skip to content

Commit 56c6691

Browse files
committed
Fix an issue when reloading a KML with adminId
with the new KML data approach, and as we do not have the metadata of the layer at app startup, the URL param parser couldn't figure out if the drawing module should be shown or not (because of a protection against legacy KML layer being loaded at startup) So instead I've completely removed any adminId passthrough when parsing legacy KML layer, this way they are never given to the "modern" app, and will not be modified by web-mapviewer (that was the goal of this protection)
1 parent 9a2f27e commit 56c6691

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

src/router/legacyPermalinkManagement.routerPlugin.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ const handleLegacyParams = (legacyParams, store, to, next) => {
176176
const urlWithoutQueryParam = window.location.href.substr(0, window.location.href.indexOf('?'))
177177
window.history.replaceState(window.history.state, document.title, urlWithoutQueryParam)
178178

179-
if ('adminId' in legacyParams) {
179+
// TODO BGDIINF_SB-2685: re-activate once on prod
180+
// we cannot let adminId get through right now because legacy KML will be broken by the new viewer if edited
181+
// (broken in a sense that they will not be usable by mf-geoadmin3 anymore)
182+
const absolutelyNot = () => false
183+
if (absolutelyNot() && 'adminId' in legacyParams) {
180184
// adminId legacy param cannot be handle above in the loop because it needs to add a layer
181185
// to the layers param, thats why we do handle after.
182186
handleLegacyKmlAdminIdParam(legacyParams, newQuery)

src/router/storeSync/LayerParamConfig.class.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import ExternalGroupOfLayers from '@/api/layers/ExternalGroupOfLayers.class'
12
import ExternalWMSLayer from '@/api/layers/ExternalWMSLayer.class'
23
import ExternalWMTSLayer from '@/api/layers/ExternalWMTSLayer.class'
3-
import ExternalGroupOfLayers from '@/api/layers/ExternalGroupOfLayers.class'
44
import KMLLayer from '@/api/layers/KMLLayer.class'
55
import LayerTypes from '@/api/layers/LayerTypes.enum'
66
import AbstractParamConfig from '@/router/storeSync/abstractParamConfig.class'
@@ -153,11 +153,7 @@ function dispatchLayersFromUrlIntoStore(store, urlParamValue) {
153153
)
154154
) {
155155
const layerObject = createLayerObject(parsedLayer)
156-
if (
157-
layerObject.type === LayerTypes.KML &&
158-
layerObject.adminId &&
159-
!layerObject.isLegacy() // TODO BGDIINF_SB-2685: remove once on prod
160-
) {
156+
if (layerObject.type === LayerTypes.KML && layerObject.adminId) {
161157
promisesForAllDispatch.push(store.dispatch('setShowDrawingOverlay', true))
162158
}
163159
log.debug(` Add layer ${parsedLayer.id} to active layers`, layerObject)

tests/e2e-cypress/integration/importTool.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ describe('The Import Tool', () => {
4747
cy.get('[data-cy="import-add-layer-button"]').should('be.visible')
4848
cy.get('[data-cy="import-result-list"]').children().should('have.length', 3).first().click()
4949
cy.wait('@wms-get-map')
50+
cy.readStoreValue('state.layers.activeLayers').should('be.empty')
5051
cy.get('[data-cy="import-add-layer-button"]').click()
51-
cy.wait('@wms-get-map')
5252
cy.readStoreValue('state.layers.activeLayers').then((activeLayers) => {
5353
expect(activeLayers).to.be.an('Array').length(1)
5454
const externalLayer = activeLayers[0]

tests/e2e-cypress/integration/legacyParamImport.cy.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ describe('Test on legacy param import', () => {
132132
expect(kmlLayer.visible).to.be.true
133133
})
134134
})
135-
it('is able to import an external KML from a legacy adminId query param', () => {
135+
// TODO BGDIINF_SB-2685: re-activate
136+
it.skip('is able to import an external KML from a legacy adminId query param', () => {
136137
cy.goToMapView({
137138
adminId: adminId,
138139
})
@@ -147,7 +148,8 @@ describe('Test on legacy param import', () => {
147148
expect(kmlLayer.adminId).to.equal(adminId)
148149
})
149150
})
150-
it("don't keep KML adminId in URL after import", () => {
151+
// TODO BGDIINF_SB-2685: re-activate
152+
it.skip("don't keep KML adminId in URL after import", () => {
151153
cy.goToMapView({
152154
adminId: adminId,
153155
})
@@ -163,7 +165,8 @@ describe('Test on legacy param import', () => {
163165
})
164166
cy.url().should('not.contain', adminId)
165167
})
166-
it('is able to import an external KML from a legacy adminId query param with other layers', () => {
168+
// TODO BGDIINF_SB-2685: re-activate
169+
it.skip('is able to import an external KML from a legacy adminId query param with other layers', () => {
167170
cy.goToMapView({
168171
adminId: adminId,
169172
layers: 'test.wms.layer,test.wmts.layer',

tests/e2e-cypress/support/drawing.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ Cypress.Commands.add('goToDrawing', (queryParams = {}, withHash = false) => {
124124
cy.readWindowValue('map')
125125
.then((map) => map.getOverlays().getLength())
126126
.as('nbOverlaysAtBeginning')
127-
cy.openDrawingMode()
127+
// opening the drawing mode if no KML with adminId defined in the URL
128+
// (otherwise, the drawing mode will be opened by default, no need to open it)
129+
if (!queryParams.layers || queryParams.layers.indexOf('@adminId=') === -1) {
130+
cy.openDrawingMode()
131+
}
128132
cy.readStoreValue('state.ui.showDrawingOverlay').should('be.true')
129133
cy.waitUntilState((state) => state.drawing.iconSets.length > 0)
130134
})

0 commit comments

Comments
 (0)