@@ -25,6 +25,7 @@ export default class BrowserCell extends Component {
2525 this . state = {
2626 showTooltip : false
2727 }
28+ this . onContextMenu = this . onContextMenu . bind ( this ) ;
2829
2930 }
3031
@@ -97,7 +98,7 @@ export default class BrowserCell extends Component {
9798 }
9899
99100 getContextMenuOptions ( constraints ) {
100- let { onEditSelectedRow } = this . props ;
101+ let { onEditSelectedRow, readonly } = this . props ;
101102 const contextMenuOptions = [ ] ;
102103
103104 const setFilterContextMenuOption = this . getSetFilterContextMenuOption ( constraints ) ;
@@ -109,15 +110,15 @@ export default class BrowserCell extends Component {
109110 const relatedObjectsContextMenuOption = this . getRelatedObjectsContextMenuOption ( ) ;
110111 relatedObjectsContextMenuOption && contextMenuOptions . push ( relatedObjectsContextMenuOption ) ;
111112
112- onEditSelectedRow && contextMenuOptions . push ( {
113+ ! readonly && onEditSelectedRow && contextMenuOptions . push ( {
113114 text : 'Edit row' ,
114115 callback : ( ) => {
115116 let { objectId, onEditSelectedRow } = this . props ;
116117 onEditSelectedRow ( true , objectId ) ;
117118 }
118119 } ) ;
119120
120- if ( this . props . type === 'Pointer' ) {
121+ if ( this . props . type === 'Pointer' ) {
121122 onEditSelectedRow && contextMenuOptions . push ( {
122123 text : 'Open pointer in new tab' ,
123124 callback : ( ) => {
@@ -135,7 +136,10 @@ export default class BrowserCell extends Component {
135136 return {
136137 text : 'Set filter...' , items : constraints . map ( constraint => {
137138 const definition = Filters . Constraints [ constraint ] ;
138- const text = `${ this . props . field } ${ definition . name } ${ definition . comparable ? ( ' ' + this . copyableValue ) : '' } ` ;
139+ // Smart ellipsis for value - if it's long trim it in the middle: Lorem ipsum dolor si... aliqua
140+ const value = this . copyableValue . length < 30 ? this . copyableValue :
141+ `${ this . copyableValue . substr ( 0 , 20 ) } ...${ this . copyableValue . substr ( this . copyableValue . length - 7 ) } ` ;
142+ const text = `${ this . props . field } ${ definition . name } ${ definition . comparable ? ( ' ' + value ) : '' } ` ;
139143 return {
140144 text,
141145 callback : this . pickFilter . bind ( this , constraint )
@@ -264,10 +268,10 @@ export default class BrowserCell extends Component {
264268 this . copyableValue = value . id ;
265269 }
266270 else if ( type === 'Array' ) {
267- if ( value [ 0 ] && typeof value [ 0 ] === 'object' && value [ 0 ] . __type === 'Pointer' ) {
271+ if ( value [ 0 ] && typeof value [ 0 ] === 'object' && value [ 0 ] . __type === 'Pointer' ) {
268272 const array = [ ] ;
269- value . map ( ( v , i ) => {
270- if ( typeof v !== 'object' || v . __type !== 'Pointer' ) {
273+ value . map ( ( v , i ) => {
274+ if ( typeof v !== 'object' || v . __type !== 'Pointer' ) {
271275 throw new Error ( 'Invalid type found in pointer array' ) ;
272276 }
273277 const object = new Parse . Object ( v . className ) ;
@@ -282,10 +286,10 @@ export default class BrowserCell extends Component {
282286 ) ;
283287 } ) ;
284288 content = < ul className = { styles . hasMore } >
285- { array . map ( a => < li > { a } </ li > ) }
289+ { array . map ( a => < li > { a } </ li > ) }
286290 </ ul >
287291 this . copyableValue = JSON . stringify ( value ) ;
288- if ( array . length > 1 ) {
292+ if ( array . length > 1 ) {
289293 classes . push ( styles . removePadding ) ;
290294 }
291295 }
@@ -339,8 +343,8 @@ export default class BrowserCell extends Component {
339343 < Pill onClick = { ( ) => setRelation ( value ) } value = 'View relation' followClick = { true } />
340344 </ div >
341345 ) : (
342- 'Relation'
343- ) ;
346+ 'Relation'
347+ ) ;
344348 this . copyableValue = undefined ;
345349 }
346350
@@ -359,7 +363,7 @@ export default class BrowserCell extends Component {
359363 className = { classes . join ( ' ' ) }
360364 style = { { width } }
361365 onClick = { ( e ) => {
362- if ( e . metaKey === true && type === 'Pointer' ) {
366+ if ( e . metaKey === true && type === 'Pointer' ) {
363367 onPointerCmdClick ( value ) ;
364368 } else {
365369 onSelect ( { row, col } ) ;
@@ -376,6 +380,7 @@ export default class BrowserCell extends Component {
376380 } , 2000 ) ;
377381 }
378382 } }
383+ onContextMenu = { this . onContextMenu }
379384 >
380385 { isNewRow ? '(auto)' : content }
381386 </ span >
@@ -386,7 +391,7 @@ export default class BrowserCell extends Component {
386391 className = { classes . join ( ' ' ) }
387392 style = { { width } }
388393 onClick = { ( e ) => {
389- if ( e . metaKey === true && type === 'Pointer' ) {
394+ if ( e . metaKey === true && type === 'Pointer' ) {
390395 onPointerCmdClick ( value ) ;
391396 }
392397 else {
@@ -411,7 +416,7 @@ export default class BrowserCell extends Component {
411416 onEditChange ( true ) ;
412417 }
413418 } }
414- onContextMenu = { this . onContextMenu . bind ( this ) }
419+ onContextMenu = { this . onContextMenu }
415420 >
416421 { content }
417422 </ span >
0 commit comments