From 0d4f85cd369166a8f89db65f850a39d69da935b1 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 15 Apr 2020 13:25:44 -0600 Subject: [PATCH] Change add to set for service settings queryParams function --- .../public/__tests__/map/service_settings.js | 16 ++++++++-------- .../maps_legacy/public/map/service_settings.js | 5 +++-- x-pack/plugins/maps/public/meta.js | 2 +- .../maps_legacy_licensing/public/plugin.ts | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js index a9272ea3966397..4cbe098501c675 100644 --- a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js +++ b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js @@ -143,24 +143,24 @@ describe('service_settings (FKA tilemaptest)', function() { } it('accepts an object', async () => { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); it('merged additions with previous values', async () => { // ensure that changes are always additive - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar', bar: 'stool' }); }); it('overwrites conflicting previous values', async () => { // ensure that conflicts are overwritten - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); - serviceSettings.addQueryParams({ foo: 'tstool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'tstool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'tstool', bar: 'stool' }); }); @@ -168,7 +168,7 @@ describe('service_settings (FKA tilemaptest)', function() { it('when overridden, should continue to work', async () => { mapConfig.emsFileApiUrl = emsFileApiUrl2; mapConfig.emsTileApiUrl = emsTileApiUrl2; - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); @@ -292,7 +292,7 @@ describe('service_settings (FKA tilemaptest)', function() { describe('File layers', function() { it('should load manifest (all props)', async function() { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); const fileLayers = await serviceSettings.getFileLayers(); expect(fileLayers.length).to.be(18); const assertions = fileLayers.map(async function(fileLayer) { diff --git a/src/plugins/maps_legacy/public/map/service_settings.js b/src/plugins/maps_legacy/public/map/service_settings.js index d6496755cd9a5c..f4f0d66ee20ded 100644 --- a/src/plugins/maps_legacy/public/map/service_settings.js +++ b/src/plugins/maps_legacy/public/map/service_settings.js @@ -152,11 +152,12 @@ export class ServiceSettings { } /** - * Add optional query-parameters to all requests + * Set optional query-parameters for all requests * * @param additionalQueryParams */ - addQueryParams(additionalQueryParams) { + setQueryParams(additionalQueryParams) { + // Functions more as a "set" than an "add" in ems-client this._emsClient.addQueryParams(additionalQueryParams); } diff --git a/x-pack/plugins/maps/public/meta.js b/x-pack/plugins/maps/public/meta.js index d4612554cf00b9..ac3a4572e0e70f 100644 --- a/x-pack/plugins/maps/public/meta.js +++ b/x-pack/plugins/maps/public/meta.js @@ -80,7 +80,7 @@ export function getEMSClient() { const licenseId = getLicenseId(); if (latestLicenseId !== licenseId) { latestLicenseId = licenseId; - emsClient.addQueryParams({ license: licenseId }); + emsClient.setQueryParams({ license: licenseId }); } return emsClient; } diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts index 14b9e94410f190..a555d3d08ff849 100644 --- a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -31,10 +31,10 @@ export class MapsLegacyLicensing if (licensing) { licensing.license$.subscribe(({ uid, isActive }: { uid: string; isActive: boolean }) => { if (isActive) { - serviceSettings.addQueryParams({ license: uid }); + serviceSettings.setQueryParams({ license: uid }); serviceSettings.disableZoomMessage(); } else { - serviceSettings.addQueryParams({ license: undefined }); + serviceSettings.setQueryParams({ license: undefined }); serviceSettings.enableZoomMessage(); } });