From 492cc244d85047d999fcb4c07b334a9910cb17d7 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 6 Oct 2018 22:14:59 +0100 Subject: [PATCH 1/5] Added hacks to fix styling issue See --- src/styles/_toolbar.scss | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/styles/_toolbar.scss b/src/styles/_toolbar.scss index 734c8ad..b3e9e0b 100644 --- a/src/styles/_toolbar.scss +++ b/src/styles/_toolbar.scss @@ -100,10 +100,17 @@ background: inherit; border-width: 0; @extend .maputnik-toolbar-link; -} -.maputnik-toolbar-select select { - margin-left: 4px; + select { + // HACK: + color: $color-black !important; + margin-left: 4px; + + option { + // HACK: + color: $color-black !important; + } + } } .maputnik-icon-text { From b0adb8cd3dc0975227287929d928e7eb044d7b51 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Thu, 25 Oct 2018 19:34:19 +0200 Subject: [PATCH 2/5] Remove style querystring parameter --- src/libs/urlopen.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libs/urlopen.js b/src/libs/urlopen.js index 20b7aa3..885d3c3 100644 --- a/src/libs/urlopen.js +++ b/src/libs/urlopen.js @@ -1,4 +1,5 @@ import url from 'url' +import querystring from 'querystring' import style from './style.js' export function initialStyleUrl() { @@ -24,6 +25,23 @@ export function loadStyleUrl(styleUrl, cb) { }) } +export function removeStyleQuerystring() { + const initialUrl = url.parse(window.location.href, true) + let qs = querystring.parse(window.location.search.slice(1)) + delete qs["style"] + if(Object.getOwnPropertyNames(qs).length === 0) { + qs = "" + } else { + qs = "?" + querystring.stringify(qs) + } + let newUrlHash = initialUrl.hash + if(newUrlHash === null) { + newUrlHash = "" + } + const newUrl = initialUrl.protocol + "//" + initialUrl.host + initialUrl.pathname + qs + newUrlHash + window.history.replaceState({}, document.title, newUrl) +} + export function loadJSON(url, defaultValue, cb) { fetch(url, { mode: 'cors', From 9cac5305cdfa6ed6b268120b7ced1db1f7c53cb8 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Thu, 25 Oct 2018 19:37:39 +0200 Subject: [PATCH 3/5] Warning when style parameter is used --- src/components/App.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index df8983c..7e9a986 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -23,7 +23,7 @@ import SurveyModal from './modals/SurveyModal' import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata' import {latest, validate} from '@mapbox/mapbox-gl-style-spec' import style from '../libs/style' -import { initialStyleUrl, loadStyleUrl } from '../libs/urlopen' +import { initialStyleUrl, loadStyleUrl, removeStyleQuerystring } from '../libs/urlopen' import { undoMessages, redoMessages } from '../libs/diffmessage' import { StyleStore } from '../libs/stylestore' import { ApiStyleStore } from '../libs/apistore' @@ -148,8 +148,11 @@ export default class App extends React.Component { const styleUrl = initialStyleUrl() if(styleUrl) { - this.styleStore = new StyleStore() - loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle)) + if(window.confirm("Load style from URL and discard current changes?")) { + this.styleStore = new StyleStore() + loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle)) + } + removeStyleQuerystring() } else { this.styleStore.init(err => { if(err) { From 9f6250c489ed349f0571d70cb378094bbb571e94 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Mon, 29 Oct 2018 11:16:27 +0100 Subject: [PATCH 4/5] Update tests --- test/functional/history/index.js | 1 + test/functional/index.js | 1 + test/functional/layers/index.js | 2 ++ test/functional/map/index.js | 2 ++ test/functional/modals/index.js | 1 + test/functional/screenshots/index.js | 6 ++++++ 6 files changed, 13 insertions(+) diff --git a/test/functional/history/index.js b/test/functional/history/index.js index e788e7e..11cf8af 100644 --- a/test/functional/history/index.js +++ b/test/functional/history/index.js @@ -13,6 +13,7 @@ describe.skip("history", function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); helper.modal.addLayer.open(); diff --git a/test/functional/index.js b/test/functional/index.js index 3c9f5ec..53e6195 100644 --- a/test/functional/index.js +++ b/test/functional/index.js @@ -11,6 +11,7 @@ describe('maputnik', function() { "geojson:example", "raster:raster" ])); + browser.alertAccept(); browser.execute(function() { localStorage.setItem("survey", true); }); diff --git a/test/functional/layers/index.js b/test/functional/layers/index.js index 012b672..048a795 100644 --- a/test/functional/layers/index.js +++ b/test/functional/layers/index.js @@ -11,6 +11,7 @@ describe("layers", function() { "geojson:example", "raster:raster" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -449,6 +450,7 @@ describe("layers", function() { browser.url(config.baseUrl+"?debug&style="+getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); helper.modal.addLayer.open(); var aId = helper.modal.addLayer.fill({ diff --git a/test/functional/map/index.js b/test/functional/map/index.js index 2df5393..816a30c 100644 --- a/test/functional/map/index.js +++ b/test/functional/map/index.js @@ -9,6 +9,7 @@ describe("map", function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])+"#"+zoomLevel+"/41.3805/2.1635"); + browser.alertAccept(); browser.waitUntil(function () { return ( @@ -22,6 +23,7 @@ describe("map", function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])+"#"+zoomLevel+"/41.3805/2.1635"); + browser.alertAccept(); browser.click(".mapboxgl-ctrl-zoom-in") browser.waitUntil(function () { diff --git a/test/functional/modals/index.js b/test/functional/modals/index.js index 0403b22..726bf09 100644 --- a/test/functional/modals/index.js +++ b/test/functional/modals/index.js @@ -99,6 +99,7 @@ describe("modals", function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.selectByValue(wd.$("nav:inspect", "select"), "inspect"); }) diff --git a/test/functional/screenshots/index.js b/test/functional/screenshots/index.js index 093802e..ef976c4 100644 --- a/test/functional/screenshots/index.js +++ b/test/functional/screenshots/index.js @@ -18,6 +18,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -28,6 +29,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -41,6 +43,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -54,6 +57,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -67,6 +71,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); @@ -80,6 +85,7 @@ describe('screenshots', function() { browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ "geojson:example" ])); + browser.alertAccept(); browser.waitForExist(".maputnik-toolbar-link"); browser.flushReactUpdates(); From 2d1675c181182e4bb579c25e4ca341cf7e486196 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Mon, 29 Oct 2018 17:35:12 +0100 Subject: [PATCH 5/5] Fixes for code review comments --- src/components/App.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 7e9a986..b6685db 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -147,13 +147,14 @@ export default class App extends React.Component { }) const styleUrl = initialStyleUrl() - if(styleUrl) { - if(window.confirm("Load style from URL and discard current changes?")) { - this.styleStore = new StyleStore() - loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle)) - } + if(styleUrl && window.confirm("Load style from URL: " + styleUrl + " and discard current changes?")) { + this.styleStore = new StyleStore() + loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle)) removeStyleQuerystring() } else { + if(styleUrl) { + removeStyleQuerystring() + } this.styleStore.init(err => { if(err) { console.log('Falling back to local storage for storing styles')