Skip to content

Commit

Permalink
Change add to set for service settings queryParams function
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 15, 2020
1 parent eeccb19 commit 0d4f85c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/plugins/maps_legacy/public/__tests__/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,32 @@ 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' });
});

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' });
});
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/maps_legacy/public/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/public/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps_legacy_licensing/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down

0 comments on commit 0d4f85c

Please sign in to comment.