Merge remote-tracking branch 'upstream/master' into feature/add-range-slider

This commit is contained in:
orangemug 2018-10-30 20:35:55 +00:00
commit a51fdb8435
9 changed files with 47 additions and 5 deletions

View file

@ -23,7 +23,7 @@ import SurveyModal from './modals/SurveyModal'
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata' import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
import {latest, validate} from '@mapbox/mapbox-gl-style-spec' import {latest, validate} from '@mapbox/mapbox-gl-style-spec'
import style from '../libs/style' 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 { undoMessages, redoMessages } from '../libs/diffmessage'
import { StyleStore } from '../libs/stylestore' import { StyleStore } from '../libs/stylestore'
import { ApiStyleStore } from '../libs/apistore' import { ApiStyleStore } from '../libs/apistore'
@ -147,10 +147,14 @@ export default class App extends React.Component {
}) })
const styleUrl = initialStyleUrl() const styleUrl = initialStyleUrl()
if(styleUrl) { if(styleUrl && window.confirm("Load style from URL: " + styleUrl + " and discard current changes?")) {
this.styleStore = new StyleStore() this.styleStore = new StyleStore()
loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle)) loadStyleUrl(styleUrl, mapStyle => this.onStyleChanged(mapStyle))
removeStyleQuerystring()
} else { } else {
if(styleUrl) {
removeStyleQuerystring()
}
this.styleStore.init(err => { this.styleStore.init(err => {
if(err) { if(err) {
console.log('Falling back to local storage for storing styles') console.log('Falling back to local storage for storing styles')

View file

@ -1,4 +1,5 @@
import url from 'url' import url from 'url'
import querystring from 'querystring'
import style from './style.js' import style from './style.js'
export function initialStyleUrl() { 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) { export function loadJSON(url, defaultValue, cb) {
fetch(url, { fetch(url, {
mode: 'cors', mode: 'cors',

View file

@ -100,10 +100,17 @@
background: inherit; background: inherit;
border-width: 0; border-width: 0;
@extend .maputnik-toolbar-link; @extend .maputnik-toolbar-link;
}
.maputnik-toolbar-select select { select {
margin-left: 4px; // HACK: <https://github.com/maputnik/editor/pull/392#issuecomment-427595172>
color: $color-black !important;
margin-left: 4px;
option {
// HACK: <https://github.com/maputnik/editor/pull/392#issuecomment-427595172>
color: $color-black !important;
}
}
} }
.maputnik-icon-text { .maputnik-icon-text {

View file

@ -13,6 +13,7 @@ describe.skip("history", function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
helper.modal.addLayer.open(); helper.modal.addLayer.open();

View file

@ -11,6 +11,7 @@ describe('maputnik', function() {
"geojson:example", "geojson:example",
"raster:raster" "raster:raster"
])); ]));
browser.alertAccept();
browser.execute(function() { browser.execute(function() {
localStorage.setItem("survey", true); localStorage.setItem("survey", true);
}); });

View file

@ -11,6 +11,7 @@ describe("layers", function() {
"geojson:example", "geojson:example",
"raster:raster" "raster:raster"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -449,6 +450,7 @@ describe("layers", function() {
browser.url(config.baseUrl+"?debug&style="+getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
helper.modal.addLayer.open(); helper.modal.addLayer.open();
var aId = helper.modal.addLayer.fill({ var aId = helper.modal.addLayer.fill({

View file

@ -9,6 +9,7 @@ describe("map", function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])+"#"+zoomLevel+"/41.3805/2.1635"); ])+"#"+zoomLevel+"/41.3805/2.1635");
browser.alertAccept();
browser.waitUntil(function () { browser.waitUntil(function () {
return ( return (
@ -22,6 +23,7 @@ describe("map", function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])+"#"+zoomLevel+"/41.3805/2.1635"); ])+"#"+zoomLevel+"/41.3805/2.1635");
browser.alertAccept();
browser.click(".mapboxgl-ctrl-zoom-in") browser.click(".mapboxgl-ctrl-zoom-in")
browser.waitUntil(function () { browser.waitUntil(function () {

View file

@ -99,6 +99,7 @@ describe("modals", function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.selectByValue(wd.$("nav:inspect", "select"), "inspect"); browser.selectByValue(wd.$("nav:inspect", "select"), "inspect");
}) })

View file

@ -18,6 +18,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -28,6 +29,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -41,6 +43,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -54,6 +57,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -67,6 +71,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();
@ -80,6 +85,7 @@ describe('screenshots', function() {
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([ browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example" "geojson:example"
])); ]));
browser.alertAccept();
browser.waitForExist(".maputnik-toolbar-link"); browser.waitForExist(".maputnik-toolbar-link");
browser.flushReactUpdates(); browser.flushReactUpdates();