Skip to content

Commit 2442d56

Browse files
authored
Merge pull request #7909 from plotly/update-server-config
Update plot config to show 'upload to cloud' button by default
2 parents aa868bb + b34dd83 commit 2442d56

10 files changed

Lines changed: 46 additions & 44 deletions

File tree

draftlogs/7909_change.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Update plot_config to show the "Upload to Cloud" button by default, and set the default server URL to cloud.plotly.com via [[#7909](https://github.com/plotly/plotly.js/pull/7909)]

src/components/modebar/buttons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ modeBarButtons.toImage = {
7272
modeBarButtons.sendChartToCloud = {
7373
name: 'sendChartToCloud',
7474
title: function (gd) {
75-
return _(gd, 'Share with Plotly Cloud');
75+
return _(gd, 'Share Chart');
7676
},
7777
icon: Icons.cloudupload,
7878
click: function (gd) {

src/components/modebar/cloud_confirm.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ module.exports = function confirmCloudDialog(gd, serverUrl, onConfirm) {
3232
.classed('plotly-cloud-dialog-title', true)
3333
.text(_(gd, 'Share with Plotly Cloud'));
3434

35-
dialog.append('div')
36-
.classed('plotly-cloud-dialog-message', true)
37-
.text(_(gd, 'This chart and its data will be sent to') + ' ' + serverUrl + '.');
35+
var serverUrlText = new URL(serverUrl).hostname;
36+
37+
var description = dialog.append('div');
38+
description.classed('plotly-cloud-dialog-message', true);
39+
description.append('span').text(_(gd, 'This chart and its data will be sent to '));
40+
description.append('span').text(serverUrlText).classed('plotly-cloud-dialog-message--hostname', true);
41+
description.append('span').text('. ');
3842

3943
var buttons = dialog.append('div')
4044
.classed('plotly-cloud-dialog-buttons', true);

src/css/_cloud_dialog.scss

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
line-height: 1.5;
4242
overflow-wrap: break-word;
4343
word-wrap: break-word;
44+
45+
&--hostname {
46+
font-weight: bold;
47+
}
4448
}
4549

4650
.plotly-cloud-dialog-buttons {
@@ -63,24 +67,24 @@
6367
outline: 2px solid vars.$color-brand-primary;
6468
outline-offset: 1px;
6569
}
66-
}
6770

68-
.plotly-cloud-dialog-btn--cancel {
69-
background-color: vars.$color-bg-light;
70-
border-color: vars.$color-bg-darker;
71-
color: vars.$color-muted-text;
72-
73-
&:hover {
71+
&--cancel {
7472
background-color: vars.$color-bg-base;
73+
margin-left: auto;
74+
color: vars.$color-muted-text;
75+
76+
&:hover {
77+
background-color: vars.$color-bg-darker;
78+
}
7579
}
76-
}
7780

78-
.plotly-cloud-dialog-btn--confirm {
79-
background-color: vars.$color-brand-primary;
80-
color: vars.$color-bg-light;
81+
&--confirm {
82+
background-color: vars.$color-brand-primary;
83+
color: vars.$color-bg-light;
8184

82-
&:hover {
83-
background-color: vars.$color-brand-accent;
85+
&:hover {
86+
background-color: vars.$color-brand-accent;
87+
}
8488
}
8589
}
8690
}

src/fonts/ploticon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module.exports = {
106106
cloudupload: {
107107
width: 640,
108108
height: 640,
109-
path: 'M176 544C96.5 544 32 479.5 32 400C32 336.6 73 282.8 129.9 263.5C128.6 255.8 128 248 128 240C128 160.5 192.5 96 272 96C327.4 96 375.5 127.3 399.6 173.1C413.8 164.8 430.4 160 448 160C501 160 544 203 544 256C544 271.7 540.2 286.6 533.5 299.7C577.5 320 608 364.4 608 416C608 486.7 550.7 544 480 544L176 544zM337 255C327.6 245.6 312.4 245.6 303.1 255L231.1 327C221.7 336.4 221.7 351.6 231.1 360.9C240.5 370.2 255.7 370.3 265 360.9L296 329.9L296 432C296 445.3 306.7 456 320 456C333.3 456 344 445.3 344 432L344 329.9L375 360.9C384.4 370.3 399.6 370.3 408.9 360.9C418.2 351.5 418.3 336.3 408.9 327L336.9 255z',
109+
path: 'M451.5 160C434.9 160 418.8 164.5 404.7 172.7C388.9 156.7 370.5 143.3 350.2 133.2C378.4 109.2 414.3 96 451.5 96C537.9 96 608 166 608 252.5C608 294 591.5 333.8 562.2 363.1L491.1 434.2C461.8 463.5 422 480 380.5 480C294.1 480 224 410 224 323.5C224 322 224 320.5 224.1 319C224.6 301.3 239.3 287.4 257 287.9C274.7 288.4 288.6 303.1 288.1 320.8C288.1 321.7 288.1 322.6 288.1 323.4C288.1 374.5 329.5 415.9 380.6 415.9C405.1 415.9 428.6 406.2 446 388.8L517.1 317.7C534.4 300.4 544.2 276.8 544.2 252.3C544.2 201.2 502.8 159.8 451.7 159.8zM307.2 237.3C305.3 236.5 303.4 235.4 301.7 234.2C289.1 227.7 274.7 224 259.6 224C235.1 224 211.6 233.7 194.2 251.1L123.1 322.2C105.8 339.5 96 363.1 96 387.6C96 438.7 137.4 480.1 188.5 480.1C205 480.1 221.1 475.7 235.2 467.5C251 483.5 269.4 496.9 289.8 507C261.6 530.9 225.8 544.2 188.5 544.2C102.1 544.2 32 474.2 32 387.7C32 346.2 48.5 306.4 77.8 277.1L148.9 206C178.2 176.7 218 160.2 259.5 160.2C346.1 160.2 416 230.8 416 317.1C416 318.4 416 319.7 416 321C415.6 338.7 400.9 352.6 383.2 352.2C365.5 351.8 351.6 337.1 352 319.4C352 318.6 352 317.9 352 317.1C352 283.4 334 253.8 307.2 237.5z',
110110
transform: 'matrix(1 0 0 1 -15 -15)'
111111
},
112112
drawopenpath: {

src/plot_api/plot_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var configAttributes = {
3333

3434
plotlyServerURL: {
3535
valType: 'string',
36-
dflt: '',
36+
dflt: 'https://cloud.plotly.com/newchart',
3737
description: [
3838
'Sets the URL for the `sendChartToCloud` modebar button.',
3939
'When clicked, the button will send the chart data to this URL.',
@@ -237,7 +237,7 @@ var configAttributes = {
237237
},
238238
showSendToCloud: {
239239
valType: 'boolean',
240-
dflt: false,
240+
dflt: true,
241241
description: [
242242
'Should we include a modebar button that sends this chart to a URL',
243243
'specified by `plotlyServerURL`, for sharing the chart with others?',

src/types/generated/schema.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16540,7 +16540,10 @@ export interface ConfigBase {
1654016540
* Range: [1, 4]
1654116541
*/
1654216542
plotGlPixelRatio?: number;
16543-
/** Sets the URL for the `sendChartToCloud` modebar button. When clicked, the button will send the chart data to this URL. */
16543+
/**
16544+
* Sets the URL for the `sendChartToCloud` modebar button. When clicked, the button will send the chart data to this URL.
16545+
* @default 'https://cloud.plotly.com/newchart'
16546+
*/
1654416547
plotlyServerURL?: string;
1654516548
/**
1654616549
* Sets the length of the undo/redo queue.
@@ -16575,7 +16578,7 @@ export interface ConfigBase {
1657516578
showAxisRangeEntryBoxes?: boolean;
1657616579
/**
1657716580
* Should we include a modebar button that sends this chart to a URL specified by `plotlyServerURL`, for sharing the chart with others? Note that this button will (after a confirmation step) send chart data to an external server.
16578-
* @default false
16581+
* @default true
1657916582
*/
1658016583
showSendToCloud?: boolean;
1658116584
/**

test/jasmine/tests/config_test.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -500,16 +500,6 @@ describe('config argument', function() {
500500

501501
afterEach(destroyGraphDiv);
502502

503-
it('should default to an empty string', function(done) {
504-
Plotly.newPlot(gd, [], {})
505-
.then(function() {
506-
expect(gd._context.plotlyServerURL).not.toBe('https://plot.ly');
507-
expect(gd._context.plotlyServerURL).not.toBe('https://chart-studio.plotly.com');
508-
expect(gd._context.plotlyServerURL).toBe('');
509-
})
510-
.then(done, done.fail);
511-
});
512-
513503
it('should open confirmation dialog when set to a correctly-formatted URL', function(done) {
514504
Plotly.newPlot(gd, [], {}, {
515505
plotlyServerURL: 'https://example.plotly.com/endpoint'
@@ -519,7 +509,7 @@ describe('config argument', function() {
519509
modeBarButtons.sendChartToCloud.click(gd);
520510
var msg = document.querySelector('.plotly-cloud-dialog-message');
521511
expect(msg).not.toBe(null, 'confirmation dialog should be shown');
522-
expect(msg.textContent).toContain('https://example.plotly.com/endpoint');
512+
expect(msg.textContent).toContain('example.plotly.com');
523513
})
524514
.then(done, done.fail);
525515
});
@@ -570,8 +560,8 @@ describe('config argument', function() {
570560

571561
var msg = document.querySelector('.plotly-cloud-dialog-message');
572562
expect(msg).not.toBe(null, 'confirmation dialog should be shown');
573-
expect(msg.textContent).toContain('https://yo.plotly.com/endpoint');
574-
expect(msg.textContent).not.toContain('https://example.plotly.com/endpoint2');
563+
expect(msg.textContent).toContain('yo.plotly.com');
564+
expect(msg.textContent).not.toContain('example.plotly.com');
575565
})
576566
.catch(failTest)
577567
.then(function() {

test/jasmine/tests/modebar_test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ describe('ModeBar', function() {
15841584
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
15851585
}
15861586

1587-
var initial = 10;
1587+
var initial = 11;
15881588
Plotly.newPlot(gd, [{y: [1, 2]}], {})
15891589
.then(function() {
15901590
expect(countButtons()).toBe(initial);
@@ -1669,7 +1669,7 @@ describe('ModeBar', function() {
16691669
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
16701670
}
16711671

1672-
var initial = 10;
1672+
var initial = 11;
16731673
Plotly.newPlot(gd, [{y: [1, 2]}], {})
16741674
.then(function() {
16751675
expect(countButtons()).toBe(initial);
@@ -1715,10 +1715,10 @@ describe('ModeBar', function() {
17151715
it('remove buttons using template', function(done) {
17161716
function countButtons() {
17171717
var modeBarEl = gd._fullLayout._modeBar.element;
1718-
return d3Select(modeBarEl).selectAll('a.modebar-btn').size();
1718+
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
17191719
}
17201720

1721-
var initial = 10;
1721+
var initial = 11;
17221722
Plotly.newPlot(gd, [{y: [1, 2]}], {
17231723
template: {
17241724
layout: {
@@ -1750,7 +1750,7 @@ describe('ModeBar', function() {
17501750
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
17511751
}
17521752

1753-
var initial = 10;
1753+
var initial = 11;
17541754
Plotly.newPlot(gd, [{y: [1, 2]}], {
17551755
template: {
17561756
layout: {
@@ -1773,7 +1773,7 @@ describe('ModeBar', function() {
17731773
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
17741774
}
17751775

1776-
var initial = 10;
1776+
var initial = 11;
17771777
Plotly.newPlot(gd, [{y: [1, 2]}], {
17781778
modebar: {
17791779
remove: t
@@ -1794,7 +1794,7 @@ describe('ModeBar', function() {
17941794
return d3Select(modeBarEl).selectAll('button.modebar-btn, a.modebar-btn').size();
17951795
}
17961796

1797-
var initial = 10;
1797+
var initial = 11;
17981798
Plotly.newPlot(gd, [{y: [1, 2]}], {
17991799
modebar: {
18001800
add: 'drawline'

test/plot-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
},
270270
"plotlyServerURL": {
271271
"description": "Sets the URL for the `sendChartToCloud` modebar button. When clicked, the button will send the chart data to this URL.",
272-
"dflt": "",
272+
"dflt": "https://cloud.plotly.com/newchart",
273273
"valType": "string"
274274
},
275275
"queueLength": {
@@ -315,7 +315,7 @@
315315
},
316316
"showSendToCloud": {
317317
"description": "Should we include a modebar button that sends this chart to a URL specified by `plotlyServerURL`, for sharing the chart with others? Note that this button will (after a confirmation step) send chart data to an external server.",
318-
"dflt": false,
318+
"dflt": true,
319319
"valType": "boolean"
320320
},
321321
"showTips": {

0 commit comments

Comments
 (0)