Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/revisionable #28

Merged
merged 16 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: composer install --prefer-dist --no-progress
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Laravel Pint
run: php vendor/bin/pint --test
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: composer install --prefer-dist --no-progress
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Pest
run: php vendor/bin/pest --stop-on-defect
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
},
"require": {
"filament/filament": "^3.2",
"venturecraft/revisionable": "1.*",
"awcodes/filament-tiptap-editor": "^3.0",
"mistralys/text-diff": "^2.0",
"spatie/laravel-permission": "^6.3",
"laravel/framework": "^10.0",
"mansoor/filament-versionable": "^0.0.6",
"ralphjsmit/laravel-filament-components": "^2.1",
"kenepa/resource-lock": "^2.0",
"rawilk/filament-password-input": "^2.0",
"ralphjsmit/laravel-filament-seo": "^1.3",
"laravel/fortify": "^1.21"
Expand Down
1,304 changes: 888 additions & 416 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function handle()
$this->call('fortify:install');

$this->call('vendor:publish', ['--provider' => "Spatie\Permission\PermissionServiceProvider"]);
$this->call('vendor:publish', ['--provider' => "Venturecraft\Revisionable\RevisionableServiceProvider"]);
$this->call('vendor:publish', ['--tag' => "seo-migrations"]);
$this->call('vendor:publish', ['--tag' => "seo-config"]);
$this->call('vendor:publish', ['--tag' => "config"]);

$this->info('Installed Spatie Permissions. Installing Fila CMS Config...');

Expand All @@ -35,6 +35,8 @@ public function handle()
}
// we need this for revisionable package
$this->call('vendor:publish', ['--tag' => 'migrations']);
$this->call('vendor:publish', ['--tag' => 'resource-lock-migrations']);


if ($this->option('run-migrations') || strtoupper($this->ask('Would you like to run migrations(Y/n)?', 'Y')) == 'Y') {
$this->info('Running migrations...');
Expand Down
30 changes: 10 additions & 20 deletions src/Filament/Resources/AbstractContentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@

namespace Portable\FilaCms\Filament\Resources;

use Filament\Forms\Form;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\View;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;

use FilamentTiptapEditor\TiptapEditor;
use FilamentTiptapEditor\Enums\TiptapOutput;
use FilamentTiptapEditor\TiptapEditor;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
use Portable\FilaCms\Filament\Forms\Components\StatusBadge;
use Portable\FilaCms\Filament\Resources\AbstractContentResource\Pages;
use Portable\FilaCms\Filament\Resources\AbstractContentResource\RelationManagers;
use Portable\FilaCms\Filament\Traits\IsProtectedResource;
use Portable\FilaCms\Models\Author;
use Portable\FilaCms\Models\Page;
use Portable\FilaCms\Models\Scopes\PublishedScope;
use Portable\FilaCms\Models\TaxonomyResource;
use RalphJSmit\Filament\Components\Forms as HandyComponents;
use RalphJSmit\Filament\SEO\SEO;
use Str;

class AbstractContentResource extends AbstractResource
{
Expand Down Expand Up @@ -116,18 +114,10 @@ function (Get $get) {
->columns(1),
Fieldset::make()
->schema([
Placeholder::make('publish_at_view')
->label('Published')
->visible(fn (?Model $record): bool => $record && $record->status === 'Published')
->content(function (?Model $record): string {
return $record->publish_at ?? '?';
}),
Placeholder::make('created_at_view')
->label('Created')
->visible(fn (?Model $record): bool => $record !== null)
->content(function (?Model $record): string {
return $record->created_at ?? '?';
}),
HandyComponents\CreatedAt::make()
->label('Created'),
HandyComponents\UpdatedAt::make()
->label('Updated'),
StatusBadge::make('status')
->live()
->badge()
Expand Down Expand Up @@ -225,7 +215,6 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
RelationManagers\RevisionsRelationManager::class,
];
}

Expand All @@ -236,6 +225,7 @@ public static function getPages(): array
'index' => Pages\ListAbstractContentResources::route('/'),
'create' => Pages\CreateAbstractContentResource::route('/create'),
'edit' => Pages\EditAbstractContentResource::route('/{record}/edit'),
'revisions' => Pages\AbstractContentResourceRevisions::route('/{record}/revisions'),
];
// @codeCoverageIgnoreEnd
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Portable\FilaCms\Filament\Resources\AbstractContentResource\Pages;

use Portable\FilaCms\Filament\Resources\AbstractContentResource;
use Mansoor\FilamentVersionable\RevisionsPage;

class AbstractContentResourceRevisions extends RevisionsPage
{
protected static string $resource = AbstractContentResource::class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Kenepa\ResourceLock\Resources\Pages\Concerns\UsesResourceLock;
use Mansoor\FilamentVersionable\Page\RevisionsAction;
use Portable\FilaCms\Filament\Resources\AbstractContentResource;

class EditAbstractContentResource extends EditRecord
{
use UsesResourceLock;
use CanCheckSlug;

protected static string $resource = AbstractContentResource::class;

protected function getHeaderActions(): array
{
return [
RevisionsAction::make(),
Actions\DeleteAction::make(),
];
}
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/Filament/Resources/AuthorResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static function getPages(): array
'index' => Pages\ListAuthors::route('/'),
'create' => Pages\CreateAuthor::route('/create'),
'edit' => Pages\EditAuthor::route('/{record}/edit'),
'revisions' => Pages\AuthorRevisions::route('/{record}/revisions'),
];
}
}
11 changes: 11 additions & 0 deletions src/Filament/Resources/AuthorResource/Pages/AuthorRevisions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Portable\FilaCms\Filament\Resources\AuthorResource\Pages;

use Portable\FilaCms\Filament\Resources\AuthorResource;
use Mansoor\FilamentVersionable\RevisionsPage;

class AuthorRevisions extends RevisionsPage
{
protected static string $resource = AuthorResource::class;
}
2 changes: 2 additions & 0 deletions src/Filament/Resources/AuthorResource/Pages/EditAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Mansoor\FilamentVersionable\Page\RevisionsAction;
use Portable\FilaCms\Filament\Resources\AuthorResource;

class EditAuthor extends EditRecord
Expand All @@ -13,6 +14,7 @@ class EditAuthor extends EditRecord
protected function getHeaderActions(): array
{
return [
RevisionsAction::make(),
Actions\DeleteAction::make(),
];
}
Expand Down
3 changes: 3 additions & 0 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

class PageResource extends AbstractContentResource
{
protected static ?string $recordTitleAttribute = 'title';

public static function getPages(): array
{
return [
'index' => Pages\ListPages::route('/'),
'create' => Pages\CreatePage::route('/create'),
'edit' => Pages\EditPage::route('/{record}/edit'),
'revisions' => Pages\PageRevisions::route('/{record}/revisions'),
];
}
}
11 changes: 11 additions & 0 deletions src/Filament/Resources/PageResource/Pages/PageRevisions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Portable\FilaCms\Filament\Resources\PageResource\Pages;

use Portable\FilaCms\Filament\Resources\AbstractContentResource\Pages\AbstractContentResourceRevisions;
use Portable\FilaCms\Filament\Resources\PageResource;

class PageRevisions extends AbstractContentResourceRevisions
{
protected static string $resource = PageResource::class;
}
1 change: 1 addition & 0 deletions src/Filament/Resources/TaxonomyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static function getPages(): array
'index' => Pages\ListTaxonomies::route('/'),
'create' => Pages\CreateTaxonomy::route('/create'),
'edit' => Pages\EditTaxonomy::route('/{record}/edit'),
'revisions' => Pages\TaxonomyRevisions::route('/{record}/revisions'),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model;
use Mansoor\FilamentVersionable\Page\RevisionsAction;
use Portable\FilaCms\Filament\Resources\TaxonomyResource;

class EditTaxonomy extends EditRecord
Expand All @@ -14,6 +15,7 @@ class EditTaxonomy extends EditRecord
protected function getHeaderActions(): array
{
return [
RevisionsAction::make(),
Actions\DeleteAction::make(),
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Portable\FilaCms\Filament\Resources\TaxonomyResource\Pages;

use Portable\FilaCms\Filament\Resources\TaxonomyResource;
use Mansoor\FilamentVersionable\RevisionsPage;

class TaxonomyRevisions extends RevisionsPage
{
protected static string $resource = TaxonomyResource::class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Portable\FilaCms\Filament\Resources\TaxonomyResource\Pages;

use Portable\FilaCms\Filament\Resources\TaxonomyTermResource;
use Mansoor\FilamentVersionable\RevisionsPage;

class TaxonomyTermRevisions extends RevisionsPage
{
protected static string $resource = TaxonomyTermResource::class;
}
Loading
Loading