Skip to content

Commit e655343

Browse files
authored
Merge pull request #173 from ndrez-outl1ne/bugfix/4.24.0
Sync ResourceTableRow with Nova 4.24.0
2 parents 4ec83e0 + 880d131 commit e655343

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Uses Spatie's [eloquent-sortable](https://github.com/spatie/eloquent-sortable) u
1010
## Requirements
1111

1212
- `php: >=8.0`
13-
- `laravel/nova: ^4.20.0`
13+
- `laravel/nova: ^4.24.0`
1414

1515
## Features
1616

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": ">=8.0",
1414
"spatie/eloquent-sortable": "^3.10.0|^4.0",
15-
"laravel/nova": "^4.20.2",
15+
"laravel/nova": "^4.24.0",
1616
"outl1ne/nova-translations-loader": "^5.0"
1717
},
1818
"repositories": [

dist/js/entry.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/ResourceTableRow.vue

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
'o1-px-2': index != 0 || shouldShowCheckboxes,
5050
'o1-py-2': !shouldShowTight,
5151
'o1-whitespace-nowrap': !field.wrapping,
52-
'o1-cursor-pointer':
53-
resource.authorizedToView && clickAction !== 'ignore',
52+
'o1-cursor-pointer': clickableRow,
5453
}"
5554
class="dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-900"
5655
>
@@ -76,6 +75,7 @@
7675
class="o1-flex o1-items-center o1-justify-end o1-space-x-0 text-gray-400"
7776
>
7877
<InlineActionDropdown
78+
v-if="shouldShowActionDropdown"
7979
:actions="availableActions"
8080
:endpoint="actionsEndpoint"
8181
:resource="resource"
@@ -220,8 +220,8 @@
220220

221221
<script>
222222
import filter from 'lodash/filter'
223-
import { Inertia } from '@inertiajs/inertia'
224223
import ReordersResources from '../mixins/ReordersResources'
224+
import { mapGetters } from 'vuex'
225225
226226
export default {
227227
emits: ['actionExecuted'],
@@ -329,6 +329,9 @@ export default {
329329
},
330330
331331
navigateToPreviewView(e) {
332+
if (!this.resource.authorizedToView) {
333+
return
334+
}
332335
this.openPreviewModal()
333336
},
334337
@@ -368,6 +371,8 @@ export default {
368371
},
369372
370373
computed: {
374+
...mapGetters(['currentUser']),
375+
371376
updateURL() {
372377
return this.$url(
373378
`/resources/${this.resourceName}/${this.resource.id.value}/edit`,
@@ -390,7 +395,42 @@ export default {
390395
},
391396
392397
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+
)
394434
},
395435
},
396436
}

0 commit comments

Comments
 (0)