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

Disable plotly server URL by default #4690

Merged
merged 5 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 10 additions & 6 deletions src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ 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'
'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.',
'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(' ')
},

Expand Down Expand Up @@ -261,10 +265,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(' ')
Expand Down
5 changes: 3 additions & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
22 changes: 19 additions & 3 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,29 @@ 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).toBe(undefined);
})
.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)
Expand Down