Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
42c9601
add button placeholder which shows chart JSON
emilykl Apr 14, 2026
8ce5512
add icon
emilykl May 11, 2026
ad9ddfc
use existing sendChartToCloud function
emilykl May 14, 2026
100da7b
update plot-schema
emilykl May 14, 2026
82f5437
Update approach to use postMessage and wait for ready signal before s…
marthacryan May 28, 2026
fddd50e
Merge branch 'master' of github.com:plotly/plotly.js into upload-to-c…
marthacryan May 28, 2026
ba91b11
Create a confirmation dialog
marthacryan May 28, 2026
717fc26
Add default URL for plotlyServerURL
marthacryan May 28, 2026
8774b9c
Update string to indicate success
marthacryan Jun 9, 2026
13b8f12
Update src/plot_api/plot_config.js
marthacryan Jun 11, 2026
a44f6ef
Add localization
marthacryan Jun 11, 2026
836d24c
Address review
marthacryan Jun 11, 2026
1f47ebd
Update default cloud URL
marthacryan Jun 11, 2026
83deac2
Update src/components/modebar/cloud_confirm.js
marthacryan Jun 11, 2026
852dc1f
Set default to false for showSendToCloud
marthacryan Jun 11, 2026
4a71e43
Merge changes
marthacryan Jun 11, 2026
ff34976
Update plot-schema in dist
marthacryan Jun 11, 2026
e5933bd
Revert "Update plot-schema in dist"
emilykl Jun 15, 2026
c1b7122
update test/plot-schema.json
emilykl Jun 15, 2026
c28c434
Update default URL for upload to empty string until plotly cloud endp…
marthacryan Jun 16, 2026
da868be
Merge branch 'upload-to-cloud-proto' of github.com:plotly/plotly.js i…
marthacryan Jun 16, 2026
bf8971a
Update src/components/modebar/cloud_confirm.js
marthacryan Jun 16, 2026
ada548c
Update src/components/modebar/buttons.js
marthacryan Jun 16, 2026
0ee9501
Move validation logic to prevent dialog opening for invalid URLs
marthacryan Jun 16, 2026
299d9a5
Merge branch 'upload-to-cloud-proto' of github.com:plotly/plotly.js i…
marthacryan Jun 16, 2026
5a7a7af
Update default for test plot schema
marthacryan Jun 16, 2026
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
Prev Previous commit
Next Next commit
Create a confirmation dialog
  • Loading branch information
marthacryan committed May 28, 2026
commit ba91b115add654f24adb40a07dbe2148884730ae
11 changes: 11 additions & 0 deletions build/plotcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ var rules = {
"X [data-title]:after": "content:attr(data-title);background:#69738a;color:#fff;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;",
"X .vertical [data-title]:before,X .vertical [data-title]:after": "top:0%;right:200%;",
"X .vertical [data-title]:before": "border:6px solid rgba(0,0,0,0);border-left-color:#69738a;margin-top:8px;margin-right:-30px;",
"X .plotly-cloud-dialog": "font-family:\"Open Sans\",verdana,arial,sans-serif;position:absolute;top:0;left:0;width:100%;height:100%;z-index:1001;display:flex;align-items:center;justify-content:center;background-color:rgba(0,0,0,.4);",
"X .plotly-cloud-dialog .plotly-cloud-dialog-box": "box-sizing:border-box;min-width:300px;max-width:420px;padding:20px 24px;background-color:#fff;border:1px solid #e0e2e5;border-radius:4px;box-shadow:0 4px 16px rgba(0,0,0,.25);font-size:13px;color:#2a3f5f;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-title": "font-size:16px;font-weight:bold;margin-bottom:12px;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-message": "line-height:1.5;overflow-wrap:break-word;word-wrap:break-word;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-buttons": "display:flex;justify-content:flex-end;margin-top:20px;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn": "font-family:inherit;font-size:13px;padding:7px 16px;margin-left:8px;border-radius:3px;border:1px solid rgba(0,0,0,0);cursor:pointer;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn:focus-visible": "outline:2px solid #447adb;outline-offset:1px;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn--cancel": "background-color:#fff;border-color:#e0e2e5;color:#777;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn--cancel:hover": "background-color:#f3f3f3;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn--confirm": "background-color:#447adb;color:#fff;",
"X .plotly-cloud-dialog .plotly-cloud-dialog-btn--confirm:hover": "background-color:#1d3b84;",
Y: "font-family:\"Open Sans\",verdana,arial,sans-serif;position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;",
"Y p": "margin:0;",
"Y .notifier-note": "min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;",
Expand Down
6 changes: 5 additions & 1 deletion src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var Plots = require('../../plots/plots');
var axisIds = require('../../plots/cartesian/axis_ids');
var Icons = require('../../fonts/ploticon');
var eraseActiveShape = require('../shapes/draw').eraseActiveShape;
var confirmCloudDialog = require('./cloud_confirm');
var Lib = require('../../lib');
var _ = Lib._;

Expand Down Expand Up @@ -72,7 +73,10 @@ modeBarButtons.sendChartToCloud = {
title: function(gd) { return _(gd, 'Share with Plotly Cloud'); },
icon: Icons.cloudupload,
click: function(gd) {
Plots.sendDataToCloud(gd);
var serverUrl = (window.PLOTLYENV || {}).BASE_URL || gd._context.plotlyServerURL;
Comment thread
marthacryan marked this conversation as resolved.
Outdated
confirmCloudDialog(gd, serverUrl, function() {
Plots.sendDataToCloud(gd);
});
}
};
Comment thread
marthacryan marked this conversation as resolved.

Expand Down
69 changes: 69 additions & 0 deletions src/components/modebar/cloud_confirm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';

var d3 = require('@plotly/d3');

/**
* Show a styled confirmation dialog before sharing a chart with Plotly Cloud.
*
* The dialog is appended to the plot's positioning container (.svg-container)
* so it is centered over the plot rather than the whole viewport. It can be
* dismissed by clicking Cancel, clicking the backdrop, or pressing Escape.
*
* @param {DOM node} gd - the graph div, used to scope the dialog to the plot
* @param {string} serverUrl - destination shown in the dialog message
* @param {function} onConfirm - called when the user confirms the upload
*/
module.exports = function confirmCloudDialog(gd, serverUrl, onConfirm) {
var container = d3.select(gd._fullLayout._paperdiv.node());

// Never stack dialogs - drop any that is already open.
container.selectAll('.plotly-cloud-dialog').remove();

var overlay = container
.append('div')
.classed('plotly-cloud-dialog', true);

var dialog = overlay.append('div')
.classed('plotly-cloud-dialog-box', true);

dialog.append('div')
.classed('plotly-cloud-dialog-title', true)
.text('Share with Plotly Cloud');
Comment thread
marthacryan marked this conversation as resolved.
Outdated

dialog.append('div')
.classed('plotly-cloud-dialog-message', true)
.text('Your chart data will be sent to ' + serverUrl + '.');

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

function close() {
overlay.remove();
document.removeEventListener('keydown', onKeydown);
}

function onKeydown(e) {
if(e.key === 'Escape' || e.keyCode === 27) close();
}
document.addEventListener('keydown', onKeydown);

// Clicking the backdrop (but not the dialog box) cancels.
overlay.on('click', function() {
if(d3.event.target === overlay.node()) close();
});

buttons.append('button')
.classed('plotly-cloud-dialog-btn', true)
.classed('plotly-cloud-dialog-btn--cancel', true)
.text('Cancel')
.on('click', close);

buttons.append('button')
.classed('plotly-cloud-dialog-btn', true)
.classed('plotly-cloud-dialog-btn--confirm', true)
.text('Share')
.on('click', function() {
close();
onConfirm();
});
};
83 changes: 83 additions & 0 deletions src/css/_cloud_dialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.plotly-cloud-dialog {
font-family: 'Open Sans', verdana, arial, sans-serif; // Because not all contexts have this specified.
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1001;

display: flex;
align-items: center;
justify-content: center;

background-color: rgba(0, 0, 0, 0.4);

.plotly-cloud-dialog-box {
box-sizing: border-box;
min-width: 300px;
max-width: 420px;
padding: 20px 24px;

background-color: $color-bg-light;
border: 1px solid $color-bg-darker;
border-radius: 4px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);

font-size: 13px;
color: #2a3f5f;
}

.plotly-cloud-dialog-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 12px;
}

.plotly-cloud-dialog-message {
line-height: 1.5;
overflow-wrap: break-word;
word-wrap: break-word;
}

.plotly-cloud-dialog-buttons {
display: flex;
justify-content: flex-end;
margin-top: 20px;
}

.plotly-cloud-dialog-btn {
font-family: inherit;
font-size: 13px;
padding: 7px 16px;
margin-left: 8px;

border-radius: 3px;
border: 1px solid transparent;
cursor: pointer;

&:focus-visible {
outline: 2px solid $color-brand-primary;
outline-offset: 1px;
}
}

.plotly-cloud-dialog-btn--cancel {
background-color: $color-bg-light;
border-color: $color-bg-darker;
color: $color-muted-text;

&:hover {
background-color: $color-bg-base;
}
}

.plotly-cloud-dialog-btn--confirm {
background-color: $color-brand-primary;
color: $color-bg-light;

&:hover {
background-color: $color-brand-accent;
}
}
}
1 change: 1 addition & 0 deletions src/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
@import "cursor.scss";
@import "modebar.scss";
@import "tooltip.scss";
@import "cloud_dialog.scss";
}
@import "notifier.scss";
Loading