From 514aef4b444e12cb8cf80c2b0407e2b4802f4558 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 26 Mar 2020 12:17:50 -0400 Subject: [PATCH 1/5] set plotlyServerUrl default to blank string --- src/plot_api/plot_config.js | 8 ++++---- test/jasmine/tests/config_test.js | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 87c3d8e4ad7..9e0fc7ef03f 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -32,7 +32,7 @@ var configAttributes = { plotlyServerURL: { valType: 'string', - dflt: 'https://plot.ly', + dflt: '', description: [ 'Sets base URL for the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', 'and the showLink/sendData on-graph link' @@ -261,10 +261,10 @@ var configAttributes = { dflt: false, description: [ 'Should we include a ModeBar button, labeled "Edit in Chart Studio",', - 'that sends this chart to plot.ly or another plotly server as specified', - 'by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0', + 'that sends this chart to plotly.com (formerly plot.ly) or another plotly server', + 'as specified by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0', 'this button was included by default, now it is opt-in using this flag.', - 'Note that this button can (depending on `plotlyServerURL`) send your data', + 'Note that this button can (depending on `plotlyServerURL` being set) send your data', 'to an external server. However that server does not persist your data', 'until you arrive at the Chart Studio and explicitly click "Save".' ].join(' ') diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 25084472885..9ce98d56264 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -501,13 +501,30 @@ describe('config argument', function() { afterEach(destroyGraphDiv); - it('should default to plotly cloud', function(done) { + it('should not default to an external plotly cloud', function(done) { Plotly.plot(gd, [], {}) .then(function() { - expect(gd._context.plotlyServerURL).toBe('https://plot.ly'); + expect(gd._context.plotlyServerURL).not.toBe('https://plot.ly'); + expect(gd._context.plotlyServerURL).not.toBe('https://plotly.com'); + expect(gd._context.plotlyServerURL).toBe(''); Plotly.Plots.sendDataToCloud(gd); - expect(form.action).toBe('https://plot.ly/external'); + expect(form.action.substring(0, 17)).toBe('http://localhost:'); + expect(form.method).toBe('post'); + }) + .catch(failTest) + .then(done); + }); + + it('should be able to connect to plotly cloud when set to https://plotly.com', function(done) { + Plotly.plot(gd, [], {}, { + plotlyServerURL: 'https://plotly.com' + }) + .then(function() { + expect(gd._context.plotlyServerURL).toBe('https://plotly.com'); + + Plotly.Plots.sendDataToCloud(gd); + expect(form.action).toBe('https://plotly.com/external'); expect(form.method).toBe('post'); }) .catch(failTest) From f6611843ecda399cca16f8a81da5d01f72070070 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 26 Mar 2020 13:27:45 -0400 Subject: [PATCH 2/5] early return from sendDataToCloud when using blank plotlyServerURL default --- src/plot_api/plot_config.js | 5 +++-- src/plots/plots.js | 5 +++-- test/jasmine/tests/config_test.js | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 9e0fc7ef03f..761b3ffbdbd 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -34,8 +34,9 @@ var configAttributes = { valType: 'string', dflt: '', description: [ - 'Sets base URL for the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', - 'and the showLink/sendData on-graph link' + 'When set it determines base URL for', + 'the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', + 'and the showLink/sendData on-graph link.' ].join(' ') }, diff --git a/src/plots/plots.js b/src/plots/plots.js index 85d32db040a..5d24930ac58 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -215,9 +215,10 @@ function positionPlayWithData(gd, container) { } plots.sendDataToCloud = function(gd) { - gd.emit('plotly_beforeexport'); - var baseUrl = (window.PLOTLYENV || {}).BASE_URL || gd._context.plotlyServerURL; + if(!baseUrl) return; + + gd.emit('plotly_beforeexport'); var hiddenformDiv = d3.select(gd) .append('div') diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 9ce98d56264..4d0332dfc12 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -509,8 +509,7 @@ describe('config argument', function() { expect(gd._context.plotlyServerURL).toBe(''); Plotly.Plots.sendDataToCloud(gd); - expect(form.action.substring(0, 17)).toBe('http://localhost:'); - expect(form.method).toBe('post'); + expect(form).toBe(undefined); }) .catch(failTest) .then(done); From 7d5492d07667d163b9cd31a850b97ce61119565b Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 26 Mar 2020 14:29:50 -0400 Subject: [PATCH 3/5] provide example base URL --- src/plot_api/plot_config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 761b3ffbdbd..5f99a3277ca 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -34,7 +34,7 @@ var configAttributes = { valType: 'string', dflt: '', description: [ - 'When set it determines base URL for', + 'When set it determines base URL e.g. \'https://plotly.com\' for', 'the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', 'and the showLink/sendData on-graph link.' ].join(' ') From 9959cb89065cee2c7bcfb07a48372babc6a591a5 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 26 Mar 2020 14:41:38 -0400 Subject: [PATCH 4/5] add extra info --- src/plot_api/plot_config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 5f99a3277ca..69d87909f0c 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -36,7 +36,10 @@ var configAttributes = { description: [ 'When set it determines base URL e.g. \'https://plotly.com\' for', 'the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', - 'and the showLink/sendData on-graph link.' + 'and the showLink/sendData on-graph link.', + 'To enable sending your data to Plotly\'s public cloud, you need to', + 'set both `plotlyServerURL` to \'https://chart-studio.plotly.com\' and', + 'also set `showSendToCloud` to true.' ].join(' ') }, From d81e59829a66796eceefd63153ba0c428255bc74 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 26 Mar 2020 14:59:36 -0400 Subject: [PATCH 5/5] apply chart-studio.plotly.com and other fixups --- src/plot_api/plot_config.js | 8 ++++---- test/jasmine/tests/config_test.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 69d87909f0c..403b748cf84 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -34,10 +34,10 @@ var configAttributes = { valType: 'string', dflt: '', description: [ - 'When set it determines base URL e.g. \'https://plotly.com\' for', - 'the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button', + 'When set it determines base URL for', + 'the \'Edit in Chart Studio\' `showEditInChartStudio`/`showSendToCloud` mode bar button', 'and the showLink/sendData on-graph link.', - 'To enable sending your data to Plotly\'s public cloud, you need to', + 'To enable sending your data to Chart Studio Cloud, you need to', 'set both `plotlyServerURL` to \'https://chart-studio.plotly.com\' and', 'also set `showSendToCloud` to true.' ].join(' ') @@ -265,7 +265,7 @@ var configAttributes = { dflt: false, description: [ 'Should we include a ModeBar button, labeled "Edit in Chart Studio",', - 'that sends this chart to plotly.com (formerly plot.ly) or another plotly server', + 'that sends this chart to chart-studio.plotly.com (formerly plot.ly) or another plotly server', 'as specified by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0', 'this button was included by default, now it is opt-in using this flag.', 'Note that this button can (depending on `plotlyServerURL` being set) send your data', diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 4d0332dfc12..48f6b818f74 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -505,7 +505,7 @@ describe('config argument', function() { Plotly.plot(gd, [], {}) .then(function() { expect(gd._context.plotlyServerURL).not.toBe('https://plot.ly'); - expect(gd._context.plotlyServerURL).not.toBe('https://plotly.com'); + expect(gd._context.plotlyServerURL).not.toBe('https://chart-studio.plotly.com'); expect(gd._context.plotlyServerURL).toBe(''); Plotly.Plots.sendDataToCloud(gd); @@ -515,15 +515,15 @@ describe('config argument', function() { .then(done); }); - it('should be able to connect to plotly cloud when set to https://plotly.com', function(done) { + it('should be able to connect to Chart Studio Cloud when set to https://chart-studio.plotly.com', function(done) { Plotly.plot(gd, [], {}, { - plotlyServerURL: 'https://plotly.com' + plotlyServerURL: 'https://chart-studio.plotly.com' }) .then(function() { - expect(gd._context.plotlyServerURL).toBe('https://plotly.com'); + expect(gd._context.plotlyServerURL).toBe('https://chart-studio.plotly.com'); Plotly.Plots.sendDataToCloud(gd); - expect(form.action).toBe('https://plotly.com/external'); + expect(form.action).toBe('https://chart-studio.plotly.com/external'); expect(form.method).toBe('post'); }) .catch(failTest)