Skip to content

Commit 6bf773f

Browse files
jasonvargaclaude
andauthored
[5.x] Authorize relationship fieldtype data (#14718)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent eecc9ed commit 6bf773f

83 files changed

Lines changed: 1173 additions & 126 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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 __('messages.relationship_item_unavailable');
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="__('messages.relationship_item_unavailable')"
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" />

resources/lang/ar.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"Always show": "عرض دائمًا",
8787
"Always Show Set Button": "دائمًا عرض زر المجموعة",
8888
"An entry will be deleted|:count entries will be deleted": "سيتم حذف إدخال واحد|:count إدخالات سيتم حذفها",
89-
"An item with this ID could not be found": "لم يتم العثور على عنصر بهذا المعرف",
9089
"and": "و",
9190
"and :count more": "و :count المزيد",
9291
"Antlers": "Antlers",

resources/lang/ar/messages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
'publish_actions_publish' => 'سيتم تطبيق التغييرات على النسخة الحالية وسيتم نشرها على الفور.',
193193
'publish_actions_schedule' => 'سيتم تطبيق التغييرات على النسخة الحالية وسيتم نشرها في التاريخ المحدد.',
194194
'publish_actions_unpublish' => 'ستتم إزالة النشر عن المراجعة الحالية.',
195+
'relationship_item_unavailable' => 'هذا العنصر غير متاح. ربما تم حذفه، أو قد لا تملك صلاحية عرضه.',
195196
'reset_password_notification_body' => 'تتلقى هذا البريد الإلكتروني لأننا تلقينا طلبًا لإعادة تعيين كلمة المرور لحسابك.',
196197
'reset_password_notification_no_action' => 'إذا لم تطلب إعادة تعيين كلمة المرور، فلا يلزم اتخاذ أي إجراء آخر.',
197198
'reset_password_notification_subject' => 'إشعار إعادة تعيين كلمة المرور',

resources/lang/az.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"Always show": "Həmişə göstər",
8787
"Always Show Set Button": "Həmişə Dəst Düyməsini Göstər",
8888
"An entry will be deleted|:count entries will be deleted": "Bir giriş silinəcək|:count giriş silinəcək",
89-
"An item with this ID could not be found": "Bu ID ilə element tapılmadı",
9089
"and": "",
9190
"and :count more": "və :count daha",
9291
"Antlers": "Antlers",

resources/lang/az/messages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
'publish_actions_publish' => 'İşləyən nüsxədəki dəyişikliklər qeydə tətbiq ediləcək və dərhal dərc ediləcək.',
193193
'publish_actions_schedule' => 'İşləyən nüsxədəki dəyişikliklər qeydə tətbiq ediləcək və seçilmiş tarixdə dərc ediləcək.',
194194
'publish_actions_unpublish' => 'Cari təkrar dərc edilməyəcək.',
195+
'relationship_item_unavailable' => 'Bu element əlçatan deyil. Silinmiş ola bilər və ya onu görməyə icazəniz olmaya bilər.',
195196
'reset_password_notification_body' => 'Bu e-poçtu şifrə sıfırlama tələbi aldığımız üçün alırsınız.',
196197
'reset_password_notification_no_action' => 'Əgər şifrə sıfırlama tələbi etməmisinizsə, heç bir əlavə tədbir görülməlidir.',
197198
'reset_password_notification_subject' => 'Şifrə Sıfırlama Bildirişi',

0 commit comments

Comments
 (0)