Files
Vasyka f7fc69077b feat(i18n): wrap 1103 hardcoded UI strings across Filament with __()
- Convert static $modelLabel/$pluralModelLabel/$title to getter methods
- Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args
- Wrap Section::make()/Fieldset::make()/Notification::make()->title() args
- Fix RelationManagers::getTitle() signature to match parent (Model, string)
- Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static)
- Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest
- Remove duplicate getters in 5 resources that had manual getModelLabel already

All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-15 05:04:24 +00:00

90 lines
2.6 KiB
PHP

<?php
namespace App\Filament\Tenant\Pages;
use Filament\Actions;
use Filament\Forms;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
class ApiTokens extends Page
{
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-key';
public static function getNavigationLabel(): string
{
return __('nav.label.API Tokens');
}
public static function getNavigationGroup(): ?string
{
return __('nav.group.Admin');
}
protected static ?int $navigationSort = 95;
protected static ?string $title = null;
public function getTitle(): string
{
return __('API Tokens');
}
protected string $view = 'filament.tenant.pages.api-tokens';
public ?string $newToken = null;
public function getTokens(): array
{
$u = auth()->user();
if (! $u) return [];
return $u->tokens()->latest()->get()->map(fn ($t) => [
'id' => $t->id,
'name' => $t->name,
'last_used_at' => $t->last_used_at?->diffForHumans() ?? '—',
'created_at' => $t->created_at->diffForHumans(),
'abilities' => is_array($t->abilities) ? implode(', ', $t->abilities) : '*',
])->all();
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('create')
->label(__('Generează token'))
->icon('heroicon-m-plus')
->schema([
Forms\Components\TextInput::make('name')
->label(__('Nume (descriere)'))
->required()
->placeholder(__('ex: app-mobil, integrare-erp')),
])
->action(function (array $data) {
$u = auth()->user();
if (! $u) return;
$token = $u->createToken($data['name']);
$this->newToken = $token->plainTextToken;
Notification::make()
->title(__('Token generat!'))
->body(__('Copiază token-ul ACUM — nu va mai fi afișat.'))
->success()
->persistent()
->send();
}),
];
}
public function deleteToken(int $id): void
{
$u = auth()->user();
if (! $u) return;
$u->tokens()->where('id', $id)->delete();
Notification::make()->title('Token revocat')->success()->send();
}
public function dismissNew(): void
{
$this->newToken = null;
}
}