49
49
'o1-px-2': index != 0 || shouldShowCheckboxes,
50
50
'o1-py-2': !shouldShowTight,
51
51
'o1-whitespace-nowrap': !field.wrapping,
52
- 'o1-cursor-pointer':
53
- resource.authorizedToView && clickAction !== 'ignore',
52
+ 'o1-cursor-pointer': clickableRow,
54
53
}"
55
54
class =" dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-900"
56
55
>
76
75
class =" o1-flex o1-items-center o1-justify-end o1-space-x-0 text-gray-400"
77
76
>
78
77
<InlineActionDropdown
78
+ v-if =" shouldShowActionDropdown"
79
79
:actions =" availableActions"
80
80
:endpoint =" actionsEndpoint"
81
81
:resource =" resource"
220
220
221
221
<script >
222
222
import filter from ' lodash/filter'
223
- import { Inertia } from ' @inertiajs/inertia'
224
223
import ReordersResources from ' ../mixins/ReordersResources'
224
+ import { mapGetters } from ' vuex'
225
225
226
226
export default {
227
227
emits: [' actionExecuted' ],
@@ -329,6 +329,9 @@ export default {
329
329
},
330
330
331
331
navigateToPreviewView (e ) {
332
+ if (! this .resource .authorizedToView ) {
333
+ return
334
+ }
332
335
this .openPreviewModal ()
333
336
},
334
337
@@ -368,6 +371,8 @@ export default {
368
371
},
369
372
370
373
computed: {
374
+ ... mapGetters ([' currentUser' ]),
375
+
371
376
updateURL () {
372
377
return this .$url (
373
378
` /resources/${ this .resourceName } /${ this .resource .id .value } /edit` ,
@@ -390,7 +395,42 @@ export default {
390
395
},
391
396
392
397
shouldShowTight () {
393
- return this .tableStyle == ' tight'
398
+ return this .tableStyle === ' tight'
399
+ },
400
+
401
+ clickableRow () {
402
+ if (this .clickAction === ' edit' ) {
403
+ return this .resource .authorizedToUpdate
404
+ } else if (this .clickAction === ' select' ) {
405
+ return this .shouldShowCheckboxes
406
+ } else if (this .clickAction === ' ignore' ) {
407
+ return false
408
+ } else if (this .clickAction === ' detail' ) {
409
+ return this .resource .authorizedToView
410
+ } else if (this .clickAction === ' preview' ) {
411
+ return this .resource .authorizedToView
412
+ } else {
413
+ return this .resource .authorizedToView
414
+ }
415
+ },
416
+
417
+ shouldShowActionDropdown () {
418
+ return this .availableActions .length > 0 || this .userHasAnyOptions
419
+ },
420
+ shouldShowPreviewLink () {
421
+ return this .resource .authorizedToView && this .resource .previewHasFields
422
+ },
423
+ userHasAnyOptions () {
424
+ return (
425
+ this .resource .authorizedToReplicate ||
426
+ this .shouldShowPreviewLink ||
427
+ this .canBeImpersonated
428
+ )
429
+ },
430
+ canBeImpersonated () {
431
+ return (
432
+ this .currentUser .canImpersonate && this .resource .authorizedToImpersonate
433
+ )
394
434
},
395
435
},
396
436
}
0 commit comments