-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Share chart button #7802
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
Open
emilykl
wants to merge
26
commits into
master
Choose a base branch
from
upload-to-cloud-proto
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Share chart button #7802
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
42c9601
add button placeholder which shows chart JSON
emilykl 8ce5512
add icon
emilykl ad9ddfc
use existing sendChartToCloud function
emilykl 100da7b
update plot-schema
emilykl 82f5437
Update approach to use postMessage and wait for ready signal before s…
marthacryan fddd50e
Merge branch 'master' of github.com:plotly/plotly.js into upload-to-c…
marthacryan ba91b11
Create a confirmation dialog
marthacryan 717fc26
Add default URL for plotlyServerURL
marthacryan 8774b9c
Update string to indicate success
marthacryan 13b8f12
Update src/plot_api/plot_config.js
marthacryan a44f6ef
Add localization
marthacryan 836d24c
Address review
marthacryan 1f47ebd
Update default cloud URL
marthacryan 83deac2
Update src/components/modebar/cloud_confirm.js
marthacryan 852dc1f
Set default to false for showSendToCloud
marthacryan 4a71e43
Merge changes
marthacryan ff34976
Update plot-schema in dist
marthacryan e5933bd
Revert "Update plot-schema in dist"
emilykl c1b7122
update test/plot-schema.json
emilykl c28c434
Update default URL for upload to empty string until plotly cloud endp…
marthacryan da868be
Merge branch 'upload-to-cloud-proto' of github.com:plotly/plotly.js i…
marthacryan bf8971a
Update src/components/modebar/cloud_confirm.js
marthacryan ada548c
Update src/components/modebar/buttons.js
marthacryan 0ee9501
Move validation logic to prevent dialog opening for invalid URLs
marthacryan 299d9a5
Merge branch 'upload-to-cloud-proto' of github.com:plotly/plotly.js i…
marthacryan 5a7a7af
Update default for test plot schema
marthacryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| 'use strict'; | ||
|
|
||
| var d3 = require('@plotly/d3'); | ||
|
|
||
| var _ = require('../../lib')._; | ||
|
|
||
| /** | ||
| * 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(_(gd, 'Share with Plotly Cloud')); | ||
|
|
||
| dialog.append('div') | ||
| .classed('plotly-cloud-dialog-message', true) | ||
| .text(_(gd, 'This chart and its 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(_(gd, 'Cancel')) | ||
| .on('click', close); | ||
|
|
||
| buttons.append('button') | ||
| .classed('plotly-cloud-dialog-btn', true) | ||
| .classed('plotly-cloud-dialog-btn--confirm', true) | ||
| .text(_(gd, 'Share')) | ||
| .on('click', function() { | ||
| close(); | ||
| onConfirm(); | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.