@@ -12,6 +12,8 @@ import Field from 'components/Field/Field.react';
1212import Label from 'components/Label/Label.react' ;
1313import Option from 'components/Dropdown/Option.react' ;
1414import Toggle from 'components/Toggle/Toggle.react' ;
15+ import TextInput from 'components/TextInput/TextInput.react' ;
16+ import styles from 'dashboard/Data/Browser/ExportSelectedRowsDialog.scss' ;
1517
1618export default class ExportSelectedRowsDialog extends React . Component {
1719 constructor ( ) {
@@ -25,11 +27,28 @@ export default class ExportSelectedRowsDialog extends React.Component {
2527 }
2628
2729 valid ( ) {
30+ if ( this . state . confirmation !== 'export all' ) {
31+ return false ;
32+ }
2833 return true ;
2934 }
3035
36+ formatBytes ( bytes ) {
37+ if ( ! + bytes ) return '0 Bytes'
38+
39+ const k = 1024
40+ const decimals = 2
41+ const sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ]
42+
43+ const i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) )
44+
45+ return `${ parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( decimals ) ) } ${ sizes [ i ] } `
46+ }
47+
48+
3149 render ( ) {
3250 let selectionLength = Object . keys ( this . props . selection ) . length ;
51+ const fileSize = new TextEncoder ( ) . encode ( JSON . stringify ( this . props . data , null , this . state . exportType === '.json' && this . state . indentation ? 2 : null ) ) . length / this . props . data . length
3352 return (
3453 < Modal
3554 type = { Modal . Types . INFO }
@@ -41,6 +60,9 @@ export default class ExportSelectedRowsDialog extends React.Component {
4160 cancelText = 'Cancel'
4261 onCancel = { this . props . onCancel }
4362 onConfirm = { ( ) => this . props . onConfirm ( this . state . exportType , this . state . indentation ) } >
63+ < div className = { styles . row } >
64+ < Label text = "Do you really want to export all rows?" description = { < span className = { styles . label } > Estimated row count: { this . props . count } < br /> Estimated export size: { this . formatBytes ( fileSize ) } </ span > } />
65+ </ div >
4466 < Field
4567 label = { < Label text = 'Select export type' /> }
4668 input = {
@@ -55,6 +77,18 @@ export default class ExportSelectedRowsDialog extends React.Component {
5577 label = { < Label text = 'Indentation' /> }
5678 input = { < Toggle value = { this . state . indentation } type = { Toggle . Types . YES_NO } onChange = { ( indentation ) => { this . setState ( { indentation} ) } } /> } />
5779 }
80+ < Field
81+ label = {
82+ < Label
83+ text = 'Confirm Export all'
84+ description = 'Enter "export all" to continue.' />
85+ }
86+ input = {
87+ < TextInput
88+ placeholder = 'export all'
89+ value = { this . state . confirmation }
90+ onChange = { ( confirmation ) => this . setState ( { confirmation } ) } />
91+ } />
5892 </ Modal >
5993 ) ;
6094 }
0 commit comments