Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh authored and github-actions[bot] committed Jan 12, 2024
1 parent c9f8c25 commit 695fd39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions src/FilamentShield.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace BezhanSalleh\FilamentShield;

use BezhanSalleh\FilamentShield\Support\Utils;
use Closure;
use Illuminate\Support\Str;
use Filament\Widgets\Widget;
use Filament\Facades\Filament;
use Filament\Support\Concerns\EvaluatesClosures;
use Filament\Widgets\TableWidget;
use Filament\Widgets\Widget;
use Filament\Widgets\WidgetConfiguration;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Lang;
use Filament\Widgets\WidgetConfiguration;
use Illuminate\Support\Str;
use Spatie\Permission\PermissionRegistrar;
use BezhanSalleh\FilamentShield\Support\Utils;
use Filament\Support\Concerns\EvaluatesClosures;

class FilamentShield
{
Expand Down Expand Up @@ -133,14 +133,15 @@ public function getResources(): ?array
);
}
})
->mapWithKeys(function($resource) {
->mapWithKeys(function ($resource) {
$name = $this->getPermissionIdentifier($resource);

return [
$name => [
'resource' => "{$name}",
'model' => Str::of($resource::getModel())->afterLast('\\'),
'fqcn' => $resource,
]
],
];
})
->sortKeys()
Expand Down Expand Up @@ -205,11 +206,12 @@ public static function getPages(): ?array
->toString()
)
->toString();

return [
$permission => [
'class' => $page,
'permission' => $permission
]
'permission' => $permission,
],
];
})
->toArray();
Expand Down Expand Up @@ -247,15 +249,15 @@ public static function getWidgets(): ?array
if (Utils::isGeneralExcludeEnabled()) {
return in_array(
needle: str(
static::getWidgetInstanceFromWidgetConfiguration($widget)
)
static::getWidgetInstanceFromWidgetConfiguration($widget)
)
->afterLast('\\')
->toString(),
haystack: Utils::getExcludedWidgets()
);
}
})
->mapWithKeys(function($widget) {
->mapWithKeys(function ($widget) {
$permission = Str::of(class_basename(static::getWidgetInstanceFromWidgetConfiguration($widget)))
->prepend(
Str::of(Utils::getWidgetPermissionPrefix())
Expand All @@ -267,8 +269,8 @@ public static function getWidgets(): ?array
return [
$permission => [
'class' => static::getWidgetInstanceFromWidgetConfiguration($widget),
'permission' => $permission
]
'permission' => $permission,
],
];
})
->toArray();
Expand Down Expand Up @@ -301,7 +303,7 @@ protected function getDefaultPermissionIdentifier(string $resource): string
->replace('_', '::');
}

protected static function getWidgetInstanceFromWidgetConfiguration(string|WidgetConfiguration $widget):string
protected static function getWidgetInstanceFromWidgetConfiguration(string | WidgetConfiguration $widget): string
{
return $widget instanceof WidgetConfiguration
? $widget->widget
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ protected static function getCustomEntities(): ?Collection
});

$entitiesPermissions = $resourcePermissions
->merge(collect(FilamentShield::getPages())->map(fn($page) => $page['permission'])->values())
->merge(collect(FilamentShield::getPages())->map(fn ($page) => $page['permission'])->values())
->merge(collect(FilamentShield::getWidgets())->map(fn ($widget) => $widget['permission'])->values())
->values();

Expand Down Expand Up @@ -484,7 +484,7 @@ public static function getCheckBoxListComponentForResource(array $entity): Compo
->afterStateUpdated(fn ($livewire, Forms\Set $set) => static::toggleSelectAllViaEntities($livewire, $set))
->selectAllAction(fn (FormAction $action, Component $component, $livewire, Forms\Set $set) => static::bulkToggleableAction($action, $component, $livewire, $set))
->deselectAllAction(fn (FormAction $action, Component $component, $livewire, Forms\Set $set) => static::bulkToggleableAction($action, $component, $livewire, $set, true))
->dehydrated(fn ($state) => !blank($state))
->dehydrated(fn ($state) => ! blank($state))
->bulkToggleable()
->gridDirection('row')
->columns(FilamentShieldPlugin::get()->getResourceCheckboxListColumns());
Expand Down

0 comments on commit 695fd39

Please sign in to comment.