Skip to content

Commit b0dc5e7

Browse files
jasonvargaclaude
andcommitted
[5.x] Soften unavailable relationship and asset item presentation
Unviewable or missing relationship and asset selections now render as a muted, non-error placeholder with a tooltip covering both the deleted and no-permission cases, instead of the red broken state. Also fixes a crash where an unauthorized asset placeholder hit a TypeError in the asset field. Frontend only; the uniform backend placeholder is unchanged so no existence oracle is introduced. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6768603 commit b0dc5e7

6 files changed

Lines changed: 24 additions & 8 deletions

File tree

resources/css/components/assets.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@
142142
box-shadow: 0 0 0 1px theme('colors.blue.DEFAULT');
143143
}
144144

145+
.asset-tile.is-invalid {
146+
@apply bg-gray-100 dark:bg-dark-650 border-gray-300 dark:border-dark-200 text-gray-600 dark:text-gray-400 cursor-default;
147+
}
148+
145149
.asset-thumbnail {
146150
@apply border border-white dark:border-dark-950;
147151
}

resources/css/components/items.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
&.invalid {
2020
.item-inner {
21-
@apply border-red-300 dark:border-dark-red bg-red-100 dark:bg-red-400 text-red-500 dark:text-red-950;
21+
@apply border-gray-300 dark:border-dark-200 bg-gray-100 dark:bg-dark-650 text-gray-600 dark:text-gray-400;
2222
}
2323
}
2424

resources/js/components/fieldtypes/assets/Asset.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ export default {
5353
},
5454

5555
label() {
56-
return this.asset.basename;
56+
return this.asset.invalid ? this.asset.id : this.asset.basename;
5757
},
5858

5959
needsAlt() {
60+
if (this.asset.invalid) return false;
61+
6062
return (this.asset.isImage || this.asset.isSvg) && !this.asset.values.alt;
63+
},
64+
65+
invalidLabel() {
66+
return __('This item is unavailable. It may have been deleted, or you may not have permission to view it.');
6167
}
6268
},
6369

@@ -66,6 +72,7 @@ export default {
6672

6773
edit() {
6874
if (this.readOnly) return;
75+
if (this.asset.invalid) return;
6976

7077
this.editing = true;
7178
},

resources/js/components/fieldtypes/assets/AssetRow.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<tr class="cursor-grab bg-white dark:bg-dark-750 hover:bg-gray-100 dark:hover:bg-dark-700">
2+
<tr class="cursor-grab bg-white dark:bg-dark-750 hover:bg-gray-100 dark:hover:bg-dark-700" :class="{ 'is-invalid': asset.invalid }">
33
<td class="flex items-center h-full">
44
<div
55
v-if="canShowSvg"
@@ -24,10 +24,11 @@
2424
v-if="showFilename"
2525
@click="editOrOpen"
2626
class="flex items-center flex-1 rtl:mr-3 ltr:ml-3 text-xs rtl:text-right ltr:text-left truncate w-full"
27-
:title="__('Edit')"
27+
:class="{ 'text-gray-600 dark:text-gray-400': asset.invalid }"
28+
:title="asset.invalid ? invalidLabel : __('Edit')"
2829
:aria-label="__('Edit Asset')"
2930
>
30-
{{ asset.basename }}
31+
{{ label }}
3132
</button>
3233

3334
<button
@@ -71,6 +72,8 @@ export default {
7172
7273
methods: {
7374
editOrOpen() {
75+
if (this.asset.invalid) return;
76+
7477
return this.readOnly ? this.open() : this.edit();
7578
}
7679
},

resources/js/components/fieldtypes/assets/AssetTile.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
'is-image': isImage && !canShowSvg,
66
'is-svg': canShowSvg,
77
'is-file': !isImage && !canShowSvg,
8+
'is-invalid': asset.invalid,
89
}"
9-
:title="label"
10+
:title="asset.invalid ? invalidLabel : label"
1011
>
1112
<asset-editor
1213
v-if="editing"
@@ -41,7 +42,7 @@
4142
<div class="asset-controls">
4243
<div class="flex items-center justify-center space-x-1 rtl:space-x-reverse">
4344
<template v-if="!readOnly">
44-
<button @click="edit" class="btn btn-icon" :title="__('Edit')">
45+
<button v-if="!asset.invalid" @click="edit" class="btn btn-icon" :title="__('Edit')">
4546
<svg-icon name="micro/sharp-pencil" class="h-4 my-2" />
4647
</button>
4748

resources/js/components/inputs/relationship/Item.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
<div
1212
v-if="item.invalid"
13-
v-tooltip.top="__('An item with this ID could not be found')"
13+
v-tooltip.top="__('This item is unavailable. It may have been deleted, or you may not have permission to view it.')"
14+
class="truncate"
1415
v-text="__(item.title)" />
1516

1617
<a v-if="!item.invalid && editable" @click.prevent="edit" v-text="__(item.title)" class="truncate" v-tooltip="item.title" :href="item.edit_url" />

0 commit comments

Comments
 (0)