Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond authored and github-actions[bot] committed Oct 15, 2024
1 parent f8e4f92 commit 683f151
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 53 deletions.
10 changes: 5 additions & 5 deletions packages/builder/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function handle()
if ($panelsToregister != null) {
if (is_array($panelsToregister)) {
foreach ($panelsToregister as $panelprovider) {
$this->registerPlugins($providerPath . '/' . $panelprovider);
$this->registerPlugins($providerPath.'/'.$panelprovider);
}
} else {
$this->registerPlugins($panelsToregister);
Expand Down Expand Up @@ -138,11 +138,11 @@ public function registerPlugins(string $providerPath): void
$newPlugins = '';

foreach ($pluginsToAdd as $plugin) {
$searchPlugin = '/' . $plugin . '/';
$searchPlugin = '/'.$plugin.'/';
if (preg_match($searchPlugin, $content)) {
warning("$plugin already registered.");
} else {
$newPlugins .= $intend . $namespace . '\\' . $plugin . $function . "\n";
$newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n";
}
}

Expand All @@ -157,7 +157,7 @@ public function registerPlugins(string $providerPath): void

$pluginsSection = " ->plugins([\n$newPlugins\n ]);";
$placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s';
$replacement = "$1\n" . $pluginsSection;
$replacement = "$1\n".$pluginsSection;
$newContent = preg_replace($placeholderPattern, $replacement, $content, 1);
}

Expand All @@ -184,7 +184,7 @@ public function getPanelProviderPath(): string|array
);
}
if (count($providers) == 1) {
$providerPath .= '/' . $providers[0]->getBasename();
$providerPath .= '/'.$providers[0]->getBasename();
}

return $providerPath;
Expand Down
75 changes: 37 additions & 38 deletions packages/builder/src/Resources/ItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@

namespace Moox\Builder\Resources;

use Filament\Forms\Form;
use Filament\Tables\Table;
use Moox\Builder\Models\Item;
use Filament\Resources\Resource;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Select;
use Camya\Filament\Forms\Components\TitleWithSlugInput;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Actions\DeleteBulkAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Actions\RestoreBulkAction;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Tables\Actions\DeleteBulkAction;
use Illuminate\Database\Eloquent\SoftDeletes;
use Filament\Tables\Actions\RestoreBulkAction;
use Camya\Filament\Forms\Components\TitleWithSlugInput;
use Moox\Builder\Models\Item;
use Moox\Builder\Resources\ItemResource\Pages\CreateItem;
use Moox\Builder\Resources\ItemResource\Pages\EditItem;
use Moox\Builder\Resources\ItemResource\Pages\ViewItem;
use Moox\Builder\Resources\ItemResource\Pages\ListItems;
use Moox\Builder\Resources\ItemResource\Pages\CreateItem;
use Moox\Builder\Resources\ItemResource\Pages\ViewItem;
use Moox\Builder\Resources\ItemResource\Widgets\ItemWidgets;

//use Moox\Core\Forms\Components\TitleWithSlugInput;
Expand Down Expand Up @@ -66,7 +66,6 @@ public static function form(Form $form): Form
fieldSlug: 'slug', // The name of the field in your model that will store the slug.
),


/*TitleWithSlugInput::make('title')
->titleLabel(__('core::core.title'))
->slugLabel(__('core::core.slug'))
Expand Down Expand Up @@ -102,8 +101,8 @@ public static function form(Form $form): Form
->color('success')
->button()
->extraAttributes(['class' => 'w-full'])
->action(fn($record) => $record->restore())
->visible(fn($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewItem),
->action(fn ($record) => $record->restore())
->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewItem),
Actions\Action::make('save')
->label(__('core::core.save'))
->color('primary')
Expand All @@ -112,7 +111,7 @@ public static function form(Form $form): Form
->action(function ($livewire) {
$livewire instanceof CreateItem ? $livewire->create() : $livewire->save();
})
->visible(fn($livewire) => $livewire instanceof CreateItem || $livewire instanceof EditItem),
->visible(fn ($livewire) => $livewire instanceof CreateItem || $livewire instanceof EditItem),
Actions\Action::make('publish')
->label(__('core::core.publish'))
->color('success')
Expand All @@ -126,7 +125,7 @@ public static function form(Form $form): Form
$livewire->form->fill($data);
$livewire instanceof CreateItem ? $livewire->create() : $livewire->save();
})
->hidden(fn($livewire, $record) => $record && $record->trashed()),
->hidden(fn ($livewire, $record) => $record && $record->trashed()),
Actions\Action::make('saveAndCreateAnother')
->label(__('core::core.save_and_create_another'))
->color('secondary')
Expand All @@ -135,35 +134,35 @@ public static function form(Form $form): Form
->action(function ($livewire) {
$livewire->saveAndCreateAnother();
})
->visible(fn($livewire) => $livewire instanceof CreateItem),
->visible(fn ($livewire) => $livewire instanceof CreateItem),
Actions\Action::make('cancel')
->label(__('core::core.cancel'))
->color('secondary')
->outlined()
->extraAttributes(['class' => 'w-full'])
->url(fn() => static::getUrl('index'))
->visible(fn($livewire) => $livewire instanceof CreateItem),
->url(fn () => static::getUrl('index'))
->visible(fn ($livewire) => $livewire instanceof CreateItem),
Actions\Action::make('edit')
->label(__('core::core.edit'))
->color('primary')
->button()
->extraAttributes(['class' => 'w-full'])
->url(fn($record) => static::getUrl('edit', ['record' => $record]))
->visible(fn($livewire, $record) => $livewire instanceof ViewItem && ! $record->trashed()),
->url(fn ($record) => static::getUrl('edit', ['record' => $record]))
->visible(fn ($livewire, $record) => $livewire instanceof ViewItem && ! $record->trashed()),
Actions\Action::make('restore')
->label(__('core::core.restore'))
->color('success')
->button()
->extraAttributes(['class' => 'w-full'])
->action(fn($record) => $record->restore())
->visible(fn($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditItem),
->action(fn ($record) => $record->restore())
->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditItem),
Actions\Action::make('delete')
->label(__('core::core.delete'))
->color('danger')
->link()
->extraAttributes(['class' => 'w-full'])
->action(fn($record) => $record->delete())
->visible(fn($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditItem),
->action(fn ($record) => $record->delete())
->visible(fn ($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditItem),
]),
Select::make('type')
->options(static::getModel()::getTypeOptions())
Expand All @@ -175,11 +174,11 @@ public static function form(Form $form): Form

Select::make('author_id')
->label(__('core::core.author'))
->options(fn() => static::getAuthorOptions())
->default(fn() => auth()->id())
->options(fn () => static::getAuthorOptions())
->default(fn () => auth()->id())
->required()
->searchable()
->visible(fn() => static::shouldShowAuthorField()),
->visible(fn () => static::shouldShowAuthorField()),
]),
// TODO: Taxonomy Plugin
])
Expand Down Expand Up @@ -222,22 +221,22 @@ public static function table(Table $table): Table
->toggleable(),
ImageColumn::make('author.avatar_url')
->label(__('core::core.author'))
->tooltip(fn($record) => $record->author?->name)
->tooltip(fn ($record) => $record->author?->name)
->alignment('center')
->circular()
->visible(fn() => static::shouldShowAuthorField())
->visible(fn () => static::shouldShowAuthorField())
->toggleable(),
TextColumn::make('type')
->label(__('core::core.type'))
->visible(! empty(config('builder.types')))
->formatStateUsing(fn($record): string => config('builder.types')[$record->type] ?? ucfirst($record->type))
->formatStateUsing(fn ($record): string => config('builder.types')[$record->type] ?? ucfirst($record->type))
->sortable(),
TextColumn::make('status')
->label(__('core::core.status'))
->alignment('center')
->badge()
->formatStateUsing(fn(string $state): string => strtoupper($state))
->color(fn(string $state): string => match ($state) {
->formatStateUsing(fn (string $state): string => strtoupper($state))
->color(fn (string $state): string => match ($state) {
'draft' => 'primary',
'published' => 'success',
'scheduled' => 'info',
Expand All @@ -256,7 +255,7 @@ public static function table(Table $table): Table
->defaultSort('slug', 'desc')
->actions([
ViewAction::make(),
EditAction::make()->hidden(fn() => in_array(static::getCurrentTab(), ['trash', 'deleted'])),
EditAction::make()->hidden(fn () => in_array(static::getCurrentTab(), ['trash', 'deleted'])),
])
->bulkActions([
DeleteBulkAction::make()->hidden(function () use ($currentTab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function getHeaderActions(): array
->using(function (array $data, string $model): Item {
return $model::create($data);
})
->hidden(fn() => $this->activeTab === 'deleted'),
->hidden(fn () => $this->activeTab === 'deleted'),
Action::make('emptyTrash')
->label(__('core::core.empty_trash'))
->icon('heroicon-o-trash')
Expand All @@ -63,7 +63,7 @@ protected function getHeaderActions(): array
->send();
})
->requiresConfirmation()
->visible(fn() => $this->activeTab === 'deleted' && Item::onlyTrashed()->exists()),
->visible(fn () => $this->activeTab === 'deleted' && Item::onlyTrashed()->exists()),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getTitle(): string
{
$title = parent::getTitle();
if ($this->isRecordTrashed()) {
$title = $title . ' - ' . __('core::core.deleted');
$title = $title.' - '.__('core::core.deleted');
}

return $title;
Expand Down
9 changes: 2 additions & 7 deletions packages/builder/tests/Feature/Item/ListItemTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

use Moox\Builder\Models\Item;
use function Pest\Livewire\livewire;

use Moox\Builder\Resources\ItemResource;
use Moox\Builder\Resources\ItemResource\Pages\ListItems;

use function Pest\Livewire\livewire;

/*_____________________________________________________
table
Expand All @@ -24,8 +24,6 @@
->assertCanSeeTableRecords($items);
});



//it('can edit an item', function () {
// $item = Item::factory()->create();
//
Expand All @@ -34,8 +32,6 @@
// ->assertRedirectTo(ItemResource::getUrl('edit', ['record' => $item->id]));
//});



/*
it('can render all tabs', function () {
config(['builder.resources.builder.tabs' => ['all']]);
Expand All @@ -51,7 +47,6 @@
});
*/


it('can render index view ', function () {
$this->get(ItemResource::getUrl('index'))->assertSuccessful();
});
Expand Down

0 comments on commit 683f151

Please sign in to comment.