Skip to content

Disable plotly server URL by default #4690

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

Merged
merged 5 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 7 additions & 6 deletions src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ 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 for',
'the \'Edit in Chart Studio\' (aka sendDataToCloud) mode bar button',
'and the showLink/sendData on-graph link.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we at least include the url for CSC in the description? I guess that should be https://chart-studio.plotly.com? Something like "To enable sending your data to Plotly's public cloud, you need to set both plotlyServerURL to 'https://chart-studio.plotly.com' and showSendToCloud to true"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Done in 7d5492d using https://plotly.com

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extra info added in 9959cb8.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks - I'd take https://plotly.com out, since I believe that's not going to work, and just include https://chart-studio.plotly.com

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not use https://plotly.com as this will confuse people, let's only use https://chart-studio.plotly.com as the example.

Let's also not call it "Plotly's public cloud" but rather "Chart Studio Cloud" please.

Finally, let's replace sendDataToCloud (which is not one of the options!) with showEditInChartStudio/showSendToCloud which are slight variants on each other...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revised in d81e598.

].join(' ')
},

Expand Down Expand Up @@ -261,10 +262,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