@@ -45,6 +45,7 @@ describe('ModeBar', function() {
4545 _fullData : [ ] ,
4646 _context : {
4747 displaylogo : true ,
48+ showSendToCloud : false ,
4849 displayModeBar : true ,
4950 modeBarButtonsToRemove : [ ] ,
5051 modeBarButtonsToAdd : [ ] ,
@@ -55,15 +56,15 @@ describe('ModeBar', function() {
5556 }
5657
5758 function countGroups ( modeBar ) {
58- return d3 . select ( modeBar . element ) . selectAll ( 'div.modebar-group' ) [ 0 ] . length ;
59+ return d3 . select ( modeBar . element ) . selectAll ( 'div.modebar-group' ) . size ( ) ;
5960 }
6061
6162 function countButtons ( modeBar ) {
62- return d3 . select ( modeBar . element ) . selectAll ( 'a.modebar-btn' ) [ 0 ] . length ;
63+ return d3 . select ( modeBar . element ) . selectAll ( 'a.modebar-btn' ) . size ( ) ;
6364 }
6465
6566 function countLogo ( modeBar ) {
66- return d3 . select ( modeBar . element ) . selectAll ( 'a.plotlyjsicon' ) [ 0 ] . length ;
67+ return d3 . select ( modeBar . element ) . selectAll ( 'a.plotlyjsicon' ) . size ( ) ;
6768 }
6869
6970 function checkBtnAttr ( modeBar , index , attr ) {
@@ -334,7 +335,7 @@ describe('ModeBar', function() {
334335
335336 it ( 'creates mode bar (unselectable cartesian version)' , function ( ) {
336337 var buttons = getButtons ( [
337- [ 'toImage' , 'sendDataToCloud' ] ,
338+ [ 'toImage' ] ,
338339 [ 'zoom2d' , 'pan2d' ] ,
339340 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
340341 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -352,7 +353,7 @@ describe('ModeBar', function() {
352353
353354 it ( 'creates mode bar (selectable scatter version)' , function ( ) {
354355 var buttons = getButtons ( [
355- [ 'toImage' , 'sendDataToCloud' ] ,
356+ [ 'toImage' ] ,
356357 [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
357358 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
358359 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -376,7 +377,7 @@ describe('ModeBar', function() {
376377
377378 it ( 'creates mode bar (selectable box version)' , function ( ) {
378379 var buttons = getButtons ( [
379- [ 'toImage' , 'sendDataToCloud' ] ,
380+ [ 'toImage' ] ,
380381 [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
381382 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
382383 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -400,7 +401,7 @@ describe('ModeBar', function() {
400401
401402 it ( 'creates mode bar (cartesian fixed-axes version)' , function ( ) {
402403 var buttons = getButtons ( [
403- [ 'toImage' , 'sendDataToCloud' ] ,
404+ [ 'toImage' ] ,
404405 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
405406 ] ) ;
406407
@@ -415,7 +416,7 @@ describe('ModeBar', function() {
415416
416417 it ( 'creates mode bar (gl3d version)' , function ( ) {
417418 var buttons = getButtons ( [
418- [ 'toImage' , 'sendDataToCloud' ] ,
419+ [ 'toImage' ] ,
419420 [ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
420421 [ 'resetCameraDefault3d' , 'resetCameraLastSave3d' ] ,
421422 [ 'hoverClosest3d' ]
@@ -432,7 +433,7 @@ describe('ModeBar', function() {
432433
433434 it ( 'creates mode bar (geo version)' , function ( ) {
434435 var buttons = getButtons ( [
435- [ 'toImage' , 'sendDataToCloud' ] ,
436+ [ 'toImage' ] ,
436437 [ 'pan2d' ] ,
437438 [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
438439 [ 'hoverClosestGeo' ]
@@ -449,7 +450,7 @@ describe('ModeBar', function() {
449450
450451 it ( 'creates mode bar (geo + selected version)' , function ( ) {
451452 var buttons = getButtons ( [
452- [ 'toImage' , 'sendDataToCloud' ] ,
453+ [ 'toImage' ] ,
453454 [ 'pan2d' , 'select2d' , 'lasso2d' ] ,
454455 [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
455456 [ 'hoverClosestGeo' ]
@@ -472,7 +473,7 @@ describe('ModeBar', function() {
472473
473474 it ( 'creates mode bar (mapbox version)' , function ( ) {
474475 var buttons = getButtons ( [
475- [ 'toImage' , 'sendDataToCloud' ] ,
476+ [ 'toImage' ] ,
476477 [ 'pan2d' ] ,
477478 [ 'resetViewMapbox' ] ,
478479 [ 'toggleHover' ]
@@ -489,7 +490,7 @@ describe('ModeBar', function() {
489490
490491 it ( 'creates mode bar (mapbox + selected version)' , function ( ) {
491492 var buttons = getButtons ( [
492- [ 'toImage' , 'sendDataToCloud' ] ,
493+ [ 'toImage' ] ,
493494 [ 'pan2d' , 'select2d' , 'lasso2d' ] ,
494495 [ 'resetViewMapbox' ] ,
495496 [ 'toggleHover' ]
@@ -512,7 +513,7 @@ describe('ModeBar', function() {
512513
513514 it ( 'creates mode bar (gl2d version)' , function ( ) {
514515 var buttons = getButtons ( [
515- [ 'toImage' , 'sendDataToCloud' ] ,
516+ [ 'toImage' ] ,
516517 [ 'zoom2d' , 'pan2d' ] ,
517518 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
518519 [ 'hoverClosestGl2d' ]
@@ -530,7 +531,7 @@ describe('ModeBar', function() {
530531
531532 it ( 'creates mode bar (pie version)' , function ( ) {
532533 var buttons = getButtons ( [
533- [ 'toImage' , 'sendDataToCloud' ] ,
534+ [ 'toImage' ] ,
534535 [ 'hoverClosestPie' ]
535536 ] ) ;
536537
@@ -545,7 +546,7 @@ describe('ModeBar', function() {
545546
546547 it ( 'creates mode bar (cartesian + gl3d version)' , function ( ) {
547548 var buttons = getButtons ( [
548- [ 'toImage' , 'sendDataToCloud' ] ,
549+ [ 'toImage' ] ,
549550 [ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
550551 [ 'resetViews' ] ,
551552 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -562,7 +563,7 @@ describe('ModeBar', function() {
562563
563564 it ( 'creates mode bar (cartesian + geo unselectable version)' , function ( ) {
564565 var buttons = getButtons ( [
565- [ 'toImage' , 'sendDataToCloud' ] ,
566+ [ 'toImage' ] ,
566567 [ 'zoom2d' , 'pan2d' ] ,
567568 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
568569 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -580,7 +581,7 @@ describe('ModeBar', function() {
580581
581582 it ( 'creates mode bar (cartesian + geo selectable version)' , function ( ) {
582583 var buttons = getButtons ( [
583- [ 'toImage' , 'sendDataToCloud' ] ,
584+ [ 'toImage' ] ,
584585 [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
585586 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
586587 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -604,7 +605,7 @@ describe('ModeBar', function() {
604605
605606 it ( 'creates mode bar (cartesian + pie version)' , function ( ) {
606607 var buttons = getButtons ( [
607- [ 'toImage' , 'sendDataToCloud' ] ,
608+ [ 'toImage' ] ,
608609 [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
609610 [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
610611 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -628,7 +629,7 @@ describe('ModeBar', function() {
628629
629630 it ( 'creates mode bar (gl3d + geo version)' , function ( ) {
630631 var buttons = getButtons ( [
631- [ 'toImage' , 'sendDataToCloud' ] ,
632+ [ 'toImage' ] ,
632633 [ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
633634 [ 'resetViews' ] ,
634635 [ 'toggleHover' ]
@@ -645,7 +646,7 @@ describe('ModeBar', function() {
645646
646647 it ( 'creates mode bar (un-selectable ternary version)' , function ( ) {
647648 var buttons = getButtons ( [
648- [ 'toImage' , 'sendDataToCloud' ] ,
649+ [ 'toImage' ] ,
649650 [ 'zoom2d' , 'pan2d' ] ,
650651 [ 'toggleHover' ]
651652 ] ) ;
@@ -661,7 +662,7 @@ describe('ModeBar', function() {
661662
662663 it ( 'creates mode bar (selectable ternary version)' , function ( ) {
663664 var buttons = getButtons ( [
664- [ 'toImage' , 'sendDataToCloud' ] ,
665+ [ 'toImage' ] ,
665666 [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
666667 [ 'toggleHover' ]
667668 ] ) ;
@@ -683,7 +684,7 @@ describe('ModeBar', function() {
683684
684685 it ( 'creates mode bar (ternary + cartesian version)' , function ( ) {
685686 var buttons = getButtons ( [
686- [ 'toImage' , 'sendDataToCloud' ] ,
687+ [ 'toImage' ] ,
687688 [ 'zoom2d' , 'pan2d' ] ,
688689 [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
689690 ] ) ;
@@ -699,7 +700,7 @@ describe('ModeBar', function() {
699700
700701 it ( 'creates mode bar (ternary + gl3d version)' , function ( ) {
701702 var buttons = getButtons ( [
702- [ 'toImage' , 'sendDataToCloud' ] ,
703+ [ 'toImage' ] ,
703704 [ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
704705 [ 'resetViews' ] ,
705706 [ 'toggleHover' ]
@@ -756,6 +757,23 @@ describe('ModeBar', function() {
756757 expect ( countLogo ( gd . _fullLayout . _modeBar ) ) . toEqual ( 0 ) ;
757758 } ) ;
758759
760+ it ( 'displays/hides cloud link according to showSendToCloud config arg' , function ( ) {
761+ var gd = getMockGraphInfo ( ) ;
762+ gd . _fullLayout . _basePlotModules = [ { name : 'pie' } ] ;
763+ manageModeBar ( gd ) ;
764+ checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
765+ [ 'toImage' ] ,
766+ [ 'hoverClosestPie' ]
767+ ] ) , 1 ) ;
768+
769+ gd . _context . showSendToCloud = true ;
770+ manageModeBar ( gd ) ;
771+ checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
772+ [ 'toImage' , 'sendDataToCloud' ] ,
773+ [ 'hoverClosestPie' ]
774+ ] ) , 1 ) ;
775+ } ) ;
776+
759777 it ( 'always displays the logo if watermark config arg is true' , function ( ) {
760778 var gd = getMockGraphInfo ( ) ;
761779 gd . _context . displaylogo = false ;
@@ -778,18 +796,20 @@ describe('ModeBar', function() {
778796 var gd = setupGraphInfo ( ) ;
779797 manageModeBar ( gd ) ;
780798
799+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 11 ) ;
800+
781801 gd . _fullLayout . _basePlotModules = [ { name : 'gl3d' } ] ;
782802 manageModeBar ( gd ) ;
783803
784- expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 10 ) ;
804+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 9 ) ;
785805 } ) ;
786806
787807 it ( 'updates mode bar buttons if modeBarButtonsToRemove changes' , function ( ) {
788808 var gd = setupGraphInfo ( ) ;
789809 manageModeBar ( gd ) ;
790810 var initialButtonCount = countButtons ( gd . _fullLayout . _modeBar ) ;
791811
792- gd . _context . modeBarButtonsToRemove = [ 'toImage' , 'sendDataToCloud ' ] ;
812+ gd . _context . modeBarButtonsToRemove = [ 'toImage' , 'zoom2d ' ] ;
793813 manageModeBar ( gd ) ;
794814
795815 expect ( countButtons ( gd . _fullLayout . _modeBar ) )
@@ -829,7 +849,7 @@ describe('ModeBar', function() {
829849
830850 var modeBar = gd . _fullLayout . _modeBar ;
831851 expect ( countGroups ( modeBar ) ) . toEqual ( 6 ) ;
832- expect ( countButtons ( modeBar ) ) . toEqual ( 11 ) ;
852+ expect ( countButtons ( modeBar ) ) . toEqual ( 10 ) ;
833853 } ) ;
834854
835855 it ( 'sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)' , function ( ) {
@@ -849,7 +869,7 @@ describe('ModeBar', function() {
849869
850870 var modeBar = gd . _fullLayout . _modeBar ;
851871 expect ( countGroups ( modeBar ) ) . toEqual ( 7 ) ;
852- expect ( countButtons ( modeBar ) ) . toEqual ( 13 ) ;
872+ expect ( countButtons ( modeBar ) ) . toEqual ( 12 ) ;
853873 } ) ;
854874
855875 it ( 'sets up buttons with fully custom modeBarButtons' , function ( ) {
0 commit comments