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

add HasNavGroupLabel and disable cluster for now #20

Merged
merged 2 commits into from
Apr 4, 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
30 changes: 30 additions & 0 deletions src/Concerns/HasNavGroupLabel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace LaraZeus\Tartarus\Concerns;

use Closure;

trait HasNavGroupLabel
{
public Closure | array $navigationGroupLabel = [];

public function navigationGroupLabel(Closure | array $resources): static
{
$this->navigationGroupLabel = $resources;

return $this;
}

public function getNavigationGroupLabel(): Closure | array
{
return $this->evaluate($this->navigationGroupLabel);
}

public function getLabel(string $resource): Closure | string
{
return array_merge(
(new static())::get()->defaultNavigationGroupLabel,
$this->getNavigationGroupLabel()
)[$resource];
}
}
29 changes: 13 additions & 16 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
namespace LaraZeus\Tartarus;

use Closure;
use LaraZeus\Tartarus\Concerns\HasNavGroupLabel;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\CompanyResource;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\EmailLogsResource;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\TagResource;
use LaraZeus\Tartarus\Filament\Pages\Deleter;

trait Configuration
{
/**
* the resources navigation group
*/
protected Closure | string $navigationGroupLabel = 'Tartarus';
use HasNavGroupLabel;

public Closure | array $defaultNavigationGroupLabel = [
Deleter::class => 'Tartarus',
CompanyResource::class => 'Tartarus',
EmailLogsResource::class => 'Tartarus',
TagResource::class => 'Tartarus',
];

protected array $tartarusModels = [
'Company' => \LaraZeus\Tartarus\Models\Company::class,
Expand All @@ -18,18 +27,6 @@ trait Configuration

protected array $disableResources = [];

public function navigationGroupLabel(Closure | string $label): static
{
$this->navigationGroupLabel = $label;

return $this;
}

public function getNavigationGroupLabel(): Closure | string
{
return $this->evaluate($this->navigationGroupLabel);
}

public function tartarusModels(array $models): static
{
$this->tartarusModels = $models;
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Clusters/System/Resources/CompanyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CompanyResource extends ChaosResource

public static function getNavigationGroup(): ?string
{
return TartarusPlugin::get()->getNavigationGroupLabel();
return TartarusPlugin::get()->getLabel(__CLASS__);
}

public static function canViewAny(): bool
Expand Down
6 changes: 4 additions & 2 deletions src/Filament/Clusters/System/Resources/EmailLogsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
use Filament\Tables\Table;
use Illuminate\Support\Facades\Mail;
use LaraZeus\Chaos\Filament\ChaosResource;
use LaraZeus\Tartarus\Filament\Clusters\System;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\EmailLogsResource\Pages;
use LaraZeus\Tartarus\TartarusPlugin;
use RickDBCN\FilamentEmail\Mail\ResendMail;
use RickDBCN\FilamentEmail\Models\Email;

class EmailLogsResource extends ChaosResource
{
protected static ?string $cluster = System::class;
public static function getNavigationGroup(): ?string
{
return TartarusPlugin::get()->getLabel(__CLASS__);
}

public static function getModel(): string
{
Expand Down
8 changes: 5 additions & 3 deletions src/Filament/Clusters/System/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
use Filament\Tables\Table;
use LaraZeus\Chaos\Filament\ChaosResource;
use LaraZeus\Chaos\Forms\Components\MultiLang;
use LaraZeus\Tartarus\Filament\Clusters\System;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\TagResource\Pages;
use LaraZeus\Tartarus\TartarusPlugin;
use Spatie\Tags\Tag;

class TagResource extends ChaosResource
{
protected static ?string $cluster = System::class;

protected static ?int $navigationSort = 5;

public static function getNavigationGroup(): ?string
{
return TartarusPlugin::get()->getLabel(__CLASS__);
}

public static function getModel(): string
{
return config('tags.tag_model');
Expand Down
8 changes: 7 additions & 1 deletion src/Filament/Pages/Deleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@
use Illuminate\Database\Eloquent\Builder;
use LaraZeus\Tartarus\Filament\Clusters\System;
use LaraZeus\Tartarus\Models\SoftDelete;
use LaraZeus\Tartarus\TartarusPlugin;

class Deleter extends Page implements HasTable
{
use InteractsWithForms;
use InteractsWithTable;

protected static ?string $cluster = System::class;
//protected static ?string $cluster = System::class;

protected static ?int $navigationSort = 99;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'zeus-tartarus::pages.deleter';

public static function getNavigationGroup(): ?string
{
return TartarusPlugin::get()->getLabel(__CLASS__);
}

public static function langFile(): string
{
return 'deleter';
Expand Down