Skip to content

Commit

Permalink
Merge pull request #21 from temandroid/patch-1-temandroid
Browse files Browse the repository at this point in the history
button fix, added russian translation
  • Loading branch information
3x1io authored Aug 24, 2023
2 parents 6cbbb33 + 22a5599 commit 9f7336c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 9 deletions.
24 changes: 24 additions & 0 deletions resources/lang/ru/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

return [
"resource" => [
"id" => "ID",
"single" => "Пользователь",
"email_verified_at" => "Email подтвержден",
"created_at" => "Создан",
"updated_at" => "Изменен",
"verified" => "Верифицирован",
"unverified" => "Не верифицирован",
"name" => "Имя",
"email" => "Email",
"password" => "Пароль",
"roles" => "Роли",
"label" => "Пользователи",
"title" => [
"create" => "Создать",
"edit" => "Редактировать",
"list" => "Пользователи",
"home" => "Пользователи"
],
]
];
5 changes: 3 additions & 2 deletions src/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public static function form(Form $form): Form

public static function table(Table $table): Table
{
return $table
!config('filament-user.impersonate') ?: $table->actions([Impersonate::make('impersonate')]);
$table
->columns([
TextColumn::make('id')
->sortable()
Expand Down Expand Up @@ -125,13 +126,13 @@ public static function table(Table $table): Table
->query(fn(Builder $query): Builder => $query->whereNull('email_verified_at')),
])
->actions([
Impersonate::make('impersonate'),
ActionGroup::make([
ViewAction::make(),
EditAction::make(),
DeleteAction::make()
]),
]);
return $table;
}

public static function getPages(): array
Expand Down
10 changes: 10 additions & 0 deletions src/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use App\Models\User;
use io3x1\FilamentUser\Resources\UserResource;
use Filament\Resources\Pages\EditRecord;
use Filament\Actions\DeleteAction;
use STS\FilamentImpersonate\Pages\Actions\Impersonate;

class EditUser extends EditRecord
{
Expand All @@ -25,4 +27,12 @@ public function getTitle(): string
{
return trans('filament-user::user.resource.title.edit');
}

protected function getActions(): array
{
!config('filament-user.impersonate') ?: $ret[] = Impersonate::make()->record($this->getRecord());
$ret[] = DeleteAction::make();

return $ret;
}
}
8 changes: 8 additions & 0 deletions src/Resources/UserResource/Pages/ListUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use io3x1\FilamentUser\Resources\UserResource;
use Filament\Resources\Pages\ListRecords;
use Filament\Actions\CreateAction;

class ListUsers extends ListRecords
{
Expand All @@ -13,4 +14,11 @@ public function getTitle(): string
{
return trans('filament-user::user.resource.title.list');
}

protected function getActions(): array
{
return [
CreateAction::make(),
];
}
}
10 changes: 10 additions & 0 deletions stubs/EditUser.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace App\Filament\Resources\UserResource\Pages;
use App\Models\User;
use App\Filament\Resources\UserResource;
use Filament\Resources\Pages\EditRecord;
use Filament\Actions\DeleteAction;
use STS\FilamentImpersonate\Pages\Actions\Impersonate;

class EditUser extends EditRecord
{
Expand All @@ -25,4 +27,12 @@ class EditUser extends EditRecord
{
return trans('filament-user::user.resource.title.edit');
}

protected function getActions(): array
{
!config('filament-user.impersonate') ?: $ret[] = Impersonate::make()->record($this->getRecord());
$ret[] = DeleteAction::make();

return $ret;
}
}
8 changes: 8 additions & 0 deletions stubs/ListUsers.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Resources\Pages\ListRecords;
use Filament\Actions\CreateAction;

class ListUsers extends ListRecords
{
Expand All @@ -13,4 +14,11 @@ class ListUsers extends ListRecords
{
return trans('filament-user::user.resource.title.list');
}

protected function getActions(): array
{
return [
CreateAction::make(),
];
}
}
8 changes: 1 addition & 7 deletions stubs/UserResource.stub
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class UserResource extends Resource

public static function table(Table $table): Table
{
!config('filament-user.impersonate') ?: $table->actions([Impersonate::make('impersonate')]);
$table
->columns([
TextColumn::make('id')
Expand Down Expand Up @@ -130,13 +131,6 @@ class UserResource extends Resource
DeleteAction::make()
]),
]);

if(config('filament-user.impersonate')){
$table->prependActions([
Impersonate::make('impersonate'),
]);
}

return $table;
}

Expand Down

0 comments on commit 9f7336c

Please sign in to comment.