55 * This source code is licensed under the license found in the LICENSE file in
66 * the root directory of this source tree.
77 */
8- import { dateStringUTC } from 'lib/DateUtils' ;
9- import getFileName from 'lib/getFileName' ;
10- import Parse from 'parse' ;
11- import Pill from 'components/Pill/Pill.react' ;
12- import React from 'react' ;
13- import styles from 'components/BrowserCell/BrowserCell.scss' ;
14- import { unselectable } from 'stylesheets/base.scss' ;
8+ import { dateStringUTC } from 'lib/DateUtils' ;
9+ import getFileName from 'lib/getFileName' ;
10+ import Parse from 'parse' ;
11+ import Pill from 'components/Pill/Pill.react' ;
12+ import React from 'react' ;
13+ import styles from 'components/BrowserCell/BrowserCell.scss' ;
14+ import { unselectable } from 'stylesheets/base.scss' ;
15+ import ReactTooltip from 'react-tooltip'
1516
16- let BrowserCell = ( { type, value, hidden, width, current, onSelect, onEditChange, setRelation, onPointerClick } ) => {
17+ let BrowserCell = ( { type, value, hidden, width, current, onSelect, onEditChange, setRelation, onPointerClick, readonly } ) => {
1718 let content = value ;
1819 let classes = [ styles . cell , unselectable ] ;
20+ let readableValue = value
21+
22+ // Set read only style
23+ readonly && classes . push ( styles . readonly )
1924 if ( hidden ) {
2025 content = '(hidden)' ;
2126 classes . push ( styles . empty ) ;
2227 } else if ( value === undefined ) {
2328 if ( type === 'ACL' ) {
24- content = 'Public Read + Write' ;
29+ readableValue = content = 'Public Read + Write' ;
2530 } else {
26- content = '(undefined)' ;
31+ readableValue = content = '(undefined)' ;
2732 classes . push ( styles . empty ) ;
2833 }
2934 } else if ( value === null ) {
30- content = '(null)' ;
35+ readableValue = content = '(null)' ;
3136 classes . push ( styles . empty ) ;
3237 } else if ( value === '' ) {
3338 content = < span > </ span > ;
@@ -38,20 +43,22 @@ let BrowserCell = ({ type, value, hidden, width, current, onSelect, onEditChange
3843 < Pill value = { value . id } />
3944 </ a >
4045 ) ;
46+ readableValue = value . id ;
4147 } else if ( type === 'Date' ) {
42- content = dateStringUTC ( value ) ;
48+ readableValue = content = dateStringUTC ( value ) ;
4349 } else if ( type === 'Boolean' ) {
44- content = value ? 'True' : 'False' ;
50+ readableValue = content = value ? 'True' : 'False' ;
4551 } else if ( type === 'Array' ) {
46- content = JSON . stringify ( value . map ( val => val instanceof Parse . Object ? val . toPointer ( ) : val ) )
52+ readableValue = content = JSON . stringify ( value . map ( val => val instanceof Parse . Object ? val . toPointer ( ) : val ) )
4753 } else if ( type === 'Object' || type === 'Bytes' ) {
48- content = JSON . stringify ( value ) ;
54+ readableValue = content = JSON . stringify ( value ) ;
4955 } else if ( type === 'File' ) {
5056 if ( value . url ( ) ) {
5157 content = < Pill value = { getFileName ( value ) } /> ;
5258 } else {
5359 content = < Pill value = { 'Uploading\u2026' } /> ;
5460 }
61+ readableValue = getFileName ( value )
5562 } else if ( type === 'ACL' ) {
5663 let pieces = [ ] ;
5764 let json = value . toJSON ( ) ;
@@ -72,34 +79,45 @@ let BrowserCell = ({ type, value, hidden, width, current, onSelect, onEditChange
7279 if ( pieces . length === 0 ) {
7380 pieces . push ( 'Master Key Only' ) ;
7481 }
75- content = pieces . join ( ', ' ) ;
82+ readableValue = content = pieces . join ( ', ' ) ;
7683 } else if ( type === 'GeoPoint' ) {
77- content = `(${ value . latitude } , ${ value . longitude } )` ;
84+ readableValue = content = `(${ value . latitude } , ${ value . longitude } )` ;
7885 } else if ( type === 'Polygon' ) {
79- content = value . coordinates . map ( coord => `(${ coord } )` )
86+ readableValue = content = value . coordinates . map ( coord => `(${ coord } )` )
8087 } else if ( type === 'Relation' ) {
8188 content = (
8289 < div style = { { textAlign : 'center' , cursor : 'pointer' } } >
8390 < Pill onClick = { ( ) => setRelation ( value ) } value = 'View relation' />
8491 </ div >
8592 ) ;
93+ readableValue = value
8694 }
8795
8896 if ( current ) {
8997 classes . push ( styles . current ) ;
9098 }
9199 return (
92- < span
93- className = { classes . join ( ' ' ) }
94- style = { { width } }
95- onClick = { onSelect }
96- onDoubleClick = { ( ) => {
97- if ( type !== 'Relation' ) {
98- onEditChange ( true )
99- }
100- } } >
101- { content }
102- </ span >
100+ readonly ?
101+ < span
102+ className = { classes . join ( ' ' ) }
103+ style = { { width } }
104+ data-tip = 'Read Only'
105+ onClick = { ( ) => onSelect ( readableValue ) } >
106+ { content }
107+ < ReactTooltip event = { 'dblclick' } place = { 'bottom' } afterShow = { ( ) => setTimeout ( ReactTooltip . hide , 2000 ) } />
108+ </ span > :
109+ < span
110+ className = { classes . join ( ' ' ) }
111+ style = { { width } }
112+ onClick = { ( ) => onSelect ( readableValue ) }
113+ onDoubleClick = { ( ) => {
114+ if ( type !== 'Relation' ) {
115+ onEditChange ( true )
116+ }
117+ } } >
118+ { content }
119+ </ span >
120+
103121 ) ;
104122} ;
105123
0 commit comments