Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPASS-618: Update Mapbox with Fixes for Reverse Proxy. #1169

Merged
merged 6 commits into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"less-cache": "^0.23.0",
"local-links": "^1.4.0",
"lodash": "^3.10.1",
"mapbox-gl": "^0.39.1",
"marked": "^0.3.5",
"marky": "^1.2.0",
"moment": "^2.10.6",
Expand Down
3 changes: 2 additions & 1 deletion src/app/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@import "../auto-update/index.less";

@import "../../node_modules/mapbox-gl/dist/mapbox-gl.css";

// Packages
// @todo don't hard-code these, style manager needs to handle package styles
@import "../internal-packages/app/styles/index.less";
Expand All @@ -22,7 +24,6 @@
@import "../internal-packages/status/styles/index.less";
@import "../internal-packages/query/styles/index.less";
@import "../internal-packages/schema/styles/index.less";
@import "../internal-packages/schema/styles/mapbox-gl.css";
@import "../internal-packages/indexes/styles/index.less";
@import "../internal-packages/explain/styles/index.less";
@import "../internal-packages/sidebar/styles/index.less";
Expand Down
49 changes: 8 additions & 41 deletions src/internal-packages/schema/lib/d3/coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const app = require('hadron-app');
const turfDistance = require('turf-distance');
const turfPoint = require('turf-point');
const turfDestination = require('turf-destination');
const mapboxgl = require('mapbox-gl/dist/mapbox-gl.js');

// const metrics = require('mongodb-js-metrics')();
// const debug = require('debug')('mongodb-compass:minicharts:geo');
Expand All @@ -16,7 +17,9 @@ const CONTROL_COLOR = '#ed271c';
const TOKEN = 'pk.eyJ1IjoibW9uZ29kYi1jb21wYXNzIiwiYSI6ImNpbWUxZjNudjAwZTZ0emtrczByanZ4MzIifQ.6Mha4zoflraopcZKOLSpYQ';

const MAPBOX_API_URL = 'https://compass-maps.mongodb.com/api.mapbox.com';
const MAPBOX_CLIENT_URL = MAPBOX_API_URL + '/mapbox-gl-js/v0.15.0/mapbox-gl.js';

mapboxgl.accessToken = TOKEN;
mapboxgl.config.API_URL = MAPBOX_API_URL;

const minicharts_d3fns_geo = function() {
// --- beginning chart setup ---
Expand All @@ -25,7 +28,6 @@ const minicharts_d3fns_geo = function() {
let map = null;
let mousedown = false;
let circleControl;
let mapboxgl;

const options = {
view: null
Expand Down Expand Up @@ -276,28 +278,6 @@ const minicharts_d3fns_geo = function() {
return this;
}

function disableMapsFeature() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to have been introduced by this PR but it looks like I can't disabled the maps feature anymore via "Privacy Settings". Even when turned off, I still get maps.

Update: See COMPASS-1431 and #1170. @durran mind reviewing and backporting to 1.8-releases (COMPASS-1432) while you're in that code?

// disable in preferences and persist
app.preferences.save('googleMaps', false);
delete window.google;
// options.view.parent.render();
}

function loadMapBoxScript(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So glad this is gone. This was ugly.

const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.src = MAPBOX_CLIENT_URL;
script.onerror = function() {
done('Error ocurred while loading MapBox script.');
};
script.onload = function() {
window.mapboxgl.config.API_URL = MAPBOX_API_URL;
done(null, window.mapboxgl);
};
document.getElementsByTagName('head')[0].appendChild(script);
}


function selectFromQuery() {
// don't update from query while dragging the circle
if (mousedown) {
Expand All @@ -321,19 +301,6 @@ const minicharts_d3fns_geo = function() {
// --- end chart setup ---

function chart(selection) {
// load mapbox script
if (!window.mapboxgl) {
loadMapBoxScript(function(err) {
if (err) {
disableMapsFeature();
} else {
chart.call(this, selection);
}
});
return;
}
mapboxgl = window.mapboxgl;

selection.each(function(data) {
function getLL(d) {
if (d instanceof mapboxgl.LngLat) return d;
Expand Down Expand Up @@ -381,20 +348,20 @@ const minicharts_d3fns_geo = function() {

// create the map once
if (!map) {
mapboxgl.accessToken = TOKEN;
map = new mapboxgl.Map({
container: innerDiv[0][0],
// not allowed to whitelabel the map without enterprise license
// not allowed to whitelabel the map ever due to OpenStreetMaps license.
// attributionControl: false,
style: 'mapbox://styles/mapbox/light-v8',
style: 'mapbox://styles/mapbox/light-v9',
center: bounds.getCenter()
});
map.dragPan.enable();
map.scrollZoom.enable();
map.boxZoom.disable();

// Add zoom and rotation controls to the map
map.addControl(new mapboxgl.Navigation({position: 'top-left'}));
const navControl = new mapboxgl.NavigationControl();
map.addControl(navControl, 'top-left');

// Setup our svg layer that we can manipulate with d3
const container = map.getCanvasContainer();
Expand Down
131 changes: 0 additions & 131 deletions test/enzyme/schema.field.test.js

This file was deleted.

99 changes: 0 additions & 99 deletions test/enzyme/schema.minicharts.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/functional/query-bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('#query-bar', function() {
.should.eventually.include('Query returned 100 documents.');
});
});
context('when applying a limit', function() {
context.skip('when applying a limit #race', function() {
it('runs schema analysis on some of the documents', function() {
return client
.inputLimitFromSchemaTab('5')
Expand Down