Skip to content

Commit b093d1d

Browse files
scott graysonscott grayson
authored andcommitted
view video page
1 parent d0fce48 commit b093d1d

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
name: phpstan
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.2'
19+
php-version: '8.1'
2020
coverage: none
2121

2222
- name: Install composer dependencies

database/migrations/2024_01_01_000002_add_external_link_support_to_library_items_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ public function down(): void
3636
});
3737
}
3838
};
39+
40+

src/Models/LibraryItem.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,23 @@ protected static function boot(): void
4747
if (empty($item->slug)) {
4848
$item->slug = static::generateUniqueSlug($item->name, $item->parent_id);
4949
}
50+
51+
// Set created_by and updated_by on creation (like Laravel does with timestamps)
52+
if (auth()->check()) {
53+
$item->created_by = auth()->id();
54+
$item->updated_by = auth()->id(); // Set both on creation
55+
}
5056
});
5157

5258
static::updating(function (self $item) {
5359
if ($item->isDirty('name') && ! $item->isDirty('slug')) {
5460
$item->slug = static::generateUniqueSlug($item->name, $item->parent_id, $item->id);
5561
}
62+
63+
// Set updated_by on updates
64+
if (auth()->check()) {
65+
$item->updated_by = auth()->id();
66+
}
5667
});
5768
}
5869

src/Resources/Pages/CreateLink.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ protected function mutateFormDataBeforeCreate(array $data): array
2121
return $data;
2222
}
2323
}
24+
25+

src/Resources/Pages/ViewLibraryItem.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class ViewLibraryItem extends ViewRecord
2323
public function getTitle(): string
2424
{
2525
$record = $this->getRecord();
26+
27+
// For external links, show the item name instead of "View External Link"
28+
if ($record->type === 'link') {
29+
return $record->name;
30+
}
31+
2632
$type = match ($record->type) {
2733
'folder' => 'Folder',
2834
'file' => 'File',
@@ -52,6 +58,7 @@ protected function getHeaderActions(): array
5258
if ($this->getRecord()->type === 'link' && $this->getRecord()->external_url) {
5359
$actions[] = Action::make('visit_link')
5460
->label('Visit Link')
61+
->color('gray')
5562
->icon('heroicon-o-arrow-top-right-on-square')
5663
->url(fn () => $this->getRecord()->external_url)
5764
->openUrlInNewTab();
@@ -115,18 +122,16 @@ public function infolist(Schema $schema): Schema
115122

116123
return $schema
117124
->components([
118-
// Video section for external links that are videos
119-
Section::make('Video')
120-
->schema([
121-
VideoEmbed::make('external_url')
122-
->visible(fn () => $record->type === 'link' && $record->isVideoUrl()),
123-
])
125+
// Video for external links that are videos (no card wrapper)
126+
VideoEmbed::make('external_url')
127+
->hiddenLabel()
124128
->visible(fn () => $record->type === 'link' && $record->isVideoUrl())
125129
->columnSpanFull(),
126130

127131
// Item details section
128-
Section::make('Item Details')
132+
Section::make()
129133
->schema([
134+
// Row 1: Name, Type
130135
Grid::make(2)
131136
->schema([
132137
TextEntry::make('name')
@@ -140,26 +145,24 @@ public function infolist(Schema $schema): Schema
140145
default => $state,
141146
}),
142147
]),
143-
TextEntry::make('external_url')
144-
->label('URL')
145-
->visible(fn () => $record->type === 'link'),
146-
TextEntry::make('link_description')
147-
->label('Description')
148-
->visible(fn () => $record->type === 'link' && $record->link_description),
148+
149+
// Row 2: Created At, Created By
149150
Grid::make(2)
150151
->schema([
151-
TextEntry::make('creator.name')
152-
->label('Created By'),
153152
TextEntry::make('created_at')
154153
->label('Created At')
155154
->dateTime(),
156-
TextEntry::make('updater.name')
157-
->label('Modified By'),
158-
TextEntry::make('updated_at')
159-
->label('Modified At')
160-
->dateTime(),
155+
TextEntry::make('creator.name')
156+
->label('Created By'),
161157
]),
162-
]),
158+
159+
// Row 3: Description (full width)
160+
TextEntry::make('link_description')
161+
->label('Description')
162+
->visible(fn () => $record->type === 'link' && $record->link_description)
163+
->columnSpanFull(),
164+
])
165+
->columnSpanFull(),
163166

164167
// Media section for files
165168
Section::make('Media')

src/Traits/HasLibraryAccess.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ public function getAccessibleRootLibraryItems()
7373
return LibraryItem::whereNull('parent_id')->forUser($this)->get();
7474
}
7575
}
76+
77+

src/Traits/HasParentFolder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ protected function getParentId(): ?int
2525
return $this->parentId;
2626
}
2727
}
28+

0 commit comments

Comments
 (0)