Interactive interface for browsing global, full-resolution satellite imagery
Fix js lint errors #1576
Benjamin King356d3dba4c6a
diff --git a/web/js/containers/info.js b/web/js/containers/info.jsindex 76977c688..75c3d279f 100644--- a/web/js/containers/info.js+++ b/web/js/containers/info.js@@ -168,5 +168,7 @@ InfoList.propTypes = {feedbackIsInitiated: PropTypes.bool,aboutClick: PropTypes.func,notificationClick: PropTypes.func,- notifications: PropTypes.object+ notifications: PropTypes.object,+ config: PropTypes.object,+ models: PropTypes.object};diff --git a/web/js/containers/modal.js b/web/js/containers/modal.jsindex b3f44a8b2..ed8e3ffd9 100644--- a/web/js/containers/modal.js+++ b/web/js/containers/modal.js@@ -132,5 +132,6 @@ ModalContainer.propTypes = {id: PropTypes.string,bodyTemplate: PropTypes.node,isOpen: PropTypes.bool,- isTemplateModal: PropTypes.bool+ isTemplateModal: PropTypes.bool,+ customProps: PropTypes.object};diff --git a/web/js/link/model.js b/web/js/link/model.jsdeleted file mode 100644index e05da8fcc..000000000--- a/web/js/link/model.js+++ /dev/null@@ -1,101 +0,0 @@-import lodashEach from 'lodash/each';-import lodashMap from 'lodash/map';-import lodashIsArray from 'lodash/isArray';-import lodashIsObject from 'lodash/isObject';-import { assign, isEmpty, forOwn, keys as lodashKeys } from 'lodash';-import util from '../util/util';--export function linkModel(config) {- var self = {};- var ENCODING_EXCEPTIONS = [- {- match: new RegExp('%2C', 'g'),- replace: ','- },- {- match: new RegExp('%3B', 'g'),- replace: ';'- },- {- match: new RegExp('%3D', 'g'),- replace: '='- }- ];- var components = [];- self.events = util.events();-- var init = function() {};-- self.register = function(component, key, dispatchLegacyUpdate, legacy) {- components.push(component);- if (component.events) {- component.events.any(function() {- // self.events.trigger('update');- });- }- return self;- };-- // Returns a serialized string containing information of the current session- self.toQueryString = function() {- var state = {};- lodashEach(components, function(component) {- component.save(state);- });- var strings = lodashMap(state, function(value, key) {- if (lodashIsArray(value)) {- var parts = [];- lodashEach(value, function(item) {- var part = '';- if (lodashIsObject(item)) {- part = item.id;- if (item.attributes && item.attributes.length > 0) {- var attributes = [];- lodashEach(item.attributes, function(attribute) {- if (attribute.value) {- attributes.push(attribute.id + '=' + attribute.value);- } else {- attributes.push(attribute.id);- }- });- part += '(' + attributes.join(',') + ')';- }- } else {- part = item;- }- parts.push(part);- });- value = parts.join(',');- }- return key + '=' + encode(value);- });- return strings.join('&');- };-- // self.load = function(state, errors, dispatchLegacyUpdate, legacy) {- // errors = errors || [];- // console.log(components);- // lodashEach(components, function(component, i) {- // // component.load(state, errors);- // console.log(component);- // // if (!isEmpty(legacy[keys[i]])) {- // // forOwn(legacy[keys[i]], (value, subKey) => {- // // console.log(component[subKey], value);- // // component[subKey] = value;- // // });- // // }- // });- // };-- var encode = function(value) {- var encoded = encodeURIComponent(value);- lodashEach(ENCODING_EXCEPTIONS, function(exception) {- encoded = encoded.replace(exception.match, exception.replace);- });- return encoded;- };-- init();-- return self;-}diff --git a/web/js/link/model.test.wip.js b/web/js/link/model.test.wip.jsdeleted file mode 100644index 25e4c70c8..000000000--- a/web/js/link/model.test.wip.js+++ /dev/null@@ -1,108 +0,0 @@-import jQuery from 'jquery';-import { linkModel } from './model';-import util from '../util/util';--var unmocked = {};--beforeAll(() => {- unmocked.getJSON = jQuery.getJSON;-});--afterEach(() => {- jQuery.getJSON = unmocked.getJSON;-});--test('query string from registered components', () => {- let c1 = {- save: function (state) {- state.foo = 1;- }- };- let c2 = {- save: function (state) {- state.bar = 2;- }- };- let model = linkModel();- model.register(c1);- model.register(c2);-- expect(model.toQueryString()).toBe('foo=1&bar=2');-});--test('values encoded', () => {- let c1 = {- save: function (state) {- state.foo = '?';- }- };- let model = linkModel();- model.register(c1);-- expect(model.toQueryString()).toBe('foo=%3F');-});--test('exceptions not encoded', () => {- var c1 = {- save: function (state) {- state.foo = ',';- }- };- let model = linkModel();- model.register(c1);-- expect(model.toQueryString()).toBe('foo=,');-});--test('shorten calls cgi script', async () => {- jQuery.getJSON = jest.fn(() => {- return jQuery.Deferred()- .resolve({- data: {- url: 'shorten'- }- });- });-- let link = linkModel();- let result = await link.shorten('foo').promise();-- expect(jQuery.getJSON).toHaveBeenCalledWith('service/link/shorten.cgi?url=foo');- expect(result.data.url).toBe('shorten');-});--test('repeated call cached', async () => {- jQuery.getJSON = jest.fn(() => {- return jQuery.Deferred()- .resolve({- data: {- url: 'shorten'- }- });- });-- let link = linkModel();- await link.shorten('foo').promise();- await link.shorten('foo').promise();-- expect(jQuery.getJSON).toHaveBeenCalledTimes(1);-});--test('update on any event', () => {- let c1 = {- events: util.events()- };- let c2 = {- events: util.events()- };- let link = linkModel();- link.register(c1);- link.register(c2);-- let call = jest.fn();- link.events.on('update', call);- c1.events.trigger('event');- c2.events.trigger('event');-- expect(call).toHaveBeenCalledTimes(2);-});diff --git a/web/js/link/ui.js b/web/js/link/ui.jsdeleted file mode 100644index 185001c38..000000000--- a/web/js/link/ui.js+++ /dev/null@@ -1,31 +0,0 @@-import lodashThrottle from 'lodash/throttle';-import util from '../util/util';--export function linkUi(models, config) {- var self = {};-- var init = function() {- models.link.events.on('update', replaceHistoryState);- };-- // Calls toQueryString to fetch updated state and returns URL- var replaceHistoryState = lodashThrottle(- function() {- if (util.browser.history) {- window.history.replaceState(- '',- '@OFFICIAL_NAME@',- '?' + models.link.toQueryString()- );- }- },- 2000,- {- leading: true,- trailing: true- }- );-- init();- return self;-}diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.jsindex dc7538958..56f252e56 100644--- a/web/js/modules/layers/util.js+++ b/web/js/modules/layers/util.js@@ -1,4 +1,4 @@-import { cloneDeep as lodashCloneDeep, isEmpty } from 'lodash';+import { cloneDeep as lodashCloneDeep } from 'lodash';import { get } from 'redux-location-state/lib/helpers';import util from '../../util/util';diff --git a/web/js/palettes/model.js b/web/js/palettes/model.jsindex be2878273..d3acf762a 100644--- a/web/js/palettes/model.js+++ b/web/js/palettes/model.js@@ -78,7 +78,7 @@ export function palettesModel(models, config) {updateLookup(layerId, groupStr);self.events.trigger('set-custom', layerId, active, groupStr);self.events.trigger('change');- const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId } );+ const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId });if (layerIndex >= 0) {models.layers[groupStr][layerIndex].custom = self[groupStr][layerId];models.layers.events.trigger('change');@@ -100,7 +100,7 @@ export function palettesModel(models, config) {updateLookup(layerId, groupStr);self.events.trigger('clear-custom', layerId, groupStr);self.events.trigger('change');- const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId } );+ const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId });if (layerIndex >= 0) {models.layers[groupStr][layerIndex].custom = self[groupStr][layerId];models.layers.events.trigger('change');@@ -125,7 +125,7 @@ export function palettesModel(models, config) {updateLookup(layerId, groupStr);self.events.trigger('range', layerId, palette.min, palette.max, groupStr);self.events.trigger('change');- const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId } );+ const layerIndex = lodashFindIndex(models.layers[groupStr], { id: layerId });if (layerIndex >= 0) {models.layers[groupStr][layerIndex].custom = self[groupStr][layerId];models.layers.events.trigger('change');