Skip to content

Commit 37f3c45

Browse files
scott graysonscott grayson
authored andcommitted
fix: implement dynamic labels at page level instead of resource level
- Remove getRecord() call from resource level (method doesn't exist) - Add getTitle() methods to EditLibraryItem and ViewLibraryItem pages - Dynamic labels now work: 'Edit File', 'Edit Folder', 'View File', 'View Folder' - Fixes the method not found error while maintaining dynamic functionality
1 parent 8648ad7 commit 37f3c45

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/Resources/LibraryItemResource.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,8 @@ class LibraryItemResource extends Resource
3131

3232
public static function getModelLabel(): string
3333
{
34-
// Check if we're in a context where we can determine the type
35-
$record = static::getRecord();
36-
37-
if ($record && $record->type) {
38-
return match($record->type) {
39-
'folder' => 'Folder',
40-
'file' => 'File',
41-
default => 'Library Item'
42-
};
43-
}
44-
34+
// For now, return a generic label since we can't access record context here
35+
// The dynamic labels will be handled at the page level where we have record access
4536
return static::$modelLabel ?? 'Library Item';
4637
}
4738

src/Resources/Pages/EditLibraryItem.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class EditLibraryItem extends EditRecord
1313
{
1414
protected static string $resource = LibraryItemResource::class;
1515

16+
public function getTitle(): string
17+
{
18+
$record = $this->getRecord();
19+
$type = $record->type === 'folder' ? 'Folder' : 'File';
20+
return "Edit {$type}";
21+
}
22+
1623
protected function getHeaderActions(): array
1724
{
1825
return [

src/Resources/Pages/ViewLibraryItem.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class ViewLibraryItem extends ViewRecord
99
{
1010
protected static string $resource = LibraryItemResource::class;
1111

12+
public function getTitle(): string
13+
{
14+
$record = $this->getRecord();
15+
$type = $record->type === 'folder' ? 'Folder' : 'File';
16+
return "View {$type}";
17+
}
18+
1219
protected function getHeaderActions(): array
1320
{
1421
return [

0 commit comments

Comments
 (0)