@@ -25,6 +25,7 @@ export default class BrowserCell extends Component {
25
25
this . state = {
26
26
showTooltip : false
27
27
}
28
+ this . onContextMenu = this . onContextMenu . bind ( this ) ;
28
29
29
30
}
30
31
@@ -97,7 +98,7 @@ export default class BrowserCell extends Component {
97
98
}
98
99
99
100
getContextMenuOptions ( constraints ) {
100
- let { onEditSelectedRow } = this . props ;
101
+ let { onEditSelectedRow, readonly } = this . props ;
101
102
const contextMenuOptions = [ ] ;
102
103
103
104
const setFilterContextMenuOption = this . getSetFilterContextMenuOption ( constraints ) ;
@@ -109,15 +110,15 @@ export default class BrowserCell extends Component {
109
110
const relatedObjectsContextMenuOption = this . getRelatedObjectsContextMenuOption ( ) ;
110
111
relatedObjectsContextMenuOption && contextMenuOptions . push ( relatedObjectsContextMenuOption ) ;
111
112
112
- onEditSelectedRow && contextMenuOptions . push ( {
113
+ ! readonly && onEditSelectedRow && contextMenuOptions . push ( {
113
114
text : 'Edit row' ,
114
115
callback : ( ) => {
115
116
let { objectId, onEditSelectedRow } = this . props ;
116
117
onEditSelectedRow ( true , objectId ) ;
117
118
}
118
119
} ) ;
119
120
120
- if ( this . props . type === 'Pointer' ) {
121
+ if ( this . props . type === 'Pointer' ) {
121
122
onEditSelectedRow && contextMenuOptions . push ( {
122
123
text : 'Open pointer in new tab' ,
123
124
callback : ( ) => {
@@ -135,7 +136,10 @@ export default class BrowserCell extends Component {
135
136
return {
136
137
text : 'Set filter...' , items : constraints . map ( constraint => {
137
138
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 ) : '' } ` ;
139
143
return {
140
144
text,
141
145
callback : this . pickFilter . bind ( this , constraint )
@@ -264,10 +268,10 @@ export default class BrowserCell extends Component {
264
268
this . copyableValue = value . id ;
265
269
}
266
270
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' ) {
268
272
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' ) {
271
275
throw new Error ( 'Invalid type found in pointer array' ) ;
272
276
}
273
277
const object = new Parse . Object ( v . className ) ;
@@ -282,10 +286,10 @@ export default class BrowserCell extends Component {
282
286
) ;
283
287
} ) ;
284
288
content = < ul className = { styles . hasMore } >
285
- { array . map ( a => < li > { a } </ li > ) }
289
+ { array . map ( a => < li > { a } </ li > ) }
286
290
</ ul >
287
291
this . copyableValue = JSON . stringify ( value ) ;
288
- if ( array . length > 1 ) {
292
+ if ( array . length > 1 ) {
289
293
classes . push ( styles . removePadding ) ;
290
294
}
291
295
}
@@ -339,8 +343,8 @@ export default class BrowserCell extends Component {
339
343
< Pill onClick = { ( ) => setRelation ( value ) } value = 'View relation' followClick = { true } />
340
344
</ div >
341
345
) : (
342
- 'Relation'
343
- ) ;
346
+ 'Relation'
347
+ ) ;
344
348
this . copyableValue = undefined ;
345
349
}
346
350
@@ -359,7 +363,7 @@ export default class BrowserCell extends Component {
359
363
className = { classes . join ( ' ' ) }
360
364
style = { { width } }
361
365
onClick = { ( e ) => {
362
- if ( e . metaKey === true && type === 'Pointer' ) {
366
+ if ( e . metaKey === true && type === 'Pointer' ) {
363
367
onPointerCmdClick ( value ) ;
364
368
} else {
365
369
onSelect ( { row, col } ) ;
@@ -376,6 +380,7 @@ export default class BrowserCell extends Component {
376
380
} , 2000 ) ;
377
381
}
378
382
} }
383
+ onContextMenu = { this . onContextMenu }
379
384
>
380
385
{ isNewRow ? '(auto)' : content }
381
386
</ span >
@@ -386,7 +391,7 @@ export default class BrowserCell extends Component {
386
391
className = { classes . join ( ' ' ) }
387
392
style = { { width } }
388
393
onClick = { ( e ) => {
389
- if ( e . metaKey === true && type === 'Pointer' ) {
394
+ if ( e . metaKey === true && type === 'Pointer' ) {
390
395
onPointerCmdClick ( value ) ;
391
396
}
392
397
else {
@@ -411,7 +416,7 @@ export default class BrowserCell extends Component {
411
416
onEditChange ( true ) ;
412
417
}
413
418
} }
414
- onContextMenu = { this . onContextMenu . bind ( this ) }
419
+ onContextMenu = { this . onContextMenu }
415
420
>
416
421
{ content }
417
422
</ span >
0 commit comments