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

Formatting of Action in a group doesn't match other Actions #48

Open
malle-pietje opened this issue Aug 9, 2023 · 6 comments
Open

Formatting of Action in a group doesn't match other Actions #48

malle-pietje opened this issue Aug 9, 2023 · 6 comments

Comments

@malle-pietje
Copy link

When adding the impersonate Action to a Group like so:

            ->actions([
                ActionGroup::make([
                    ViewAction::make(),
                    EditAction::make(),
                    DeleteAction::make(),
                    Impersonate::make()->redirectTo('/admin'),
                ]),
            ]);

the styling isn't the same, nor does the label appear:
image

image

Is this caused by my incorrect usage of the plugin or is it a bug?

@jszobody
Copy link
Member

jszobody commented Aug 9, 2023

Hmm. I don't think we set a label for the table action, since it's usually desirable to just show an action with no label when it's inline.

I bet you could do Impersonate::make()->label('Impersonate')->redirectTo('/admin') yourself in the group, can you try that?

Not sure what the best solution here is. I like it being just an icon when inline, but clearly it needs a label in a group like this.

@malle-pietje
Copy link
Author

Hmm. I don't think we set a label for the table action, since it's usually desirable to just show an action with no label when it's inline.

I bet you could do Impersonate::make()->label('Impersonate')->redirectTo('/admin') yourself in the group, can you try that?

Not sure what the best solution here is. I like it being just an icon when inline, but clearly it needs a label in a group like this.

Thanks. I had already tried that but that doesn't generate label like the other elements in the group. It's not crucial; if I can find the time I'll see how this can best be achieved.

@malle-pietje
Copy link
Author

I changed the code for STS\FilamentImpersonate\Tables\Actions\Impersonate to this:

    protected function setUp(): void
    {
        parent::setUp();

//        $this
//            ->iconButton()
//            ->icon('impersonate-icon')
//            ->action(fn ($record) => $this->impersonate($record))
//            ->hidden(fn ($record) => !$this->canBeImpersonated($record));
        $this->icon('impersonate-icon');
        $this->color('primary');
        $this->action(fn ($record) => $this->impersonate($record));
        $this->hidden(fn ($record) => !$this->canBeImpersonated($record));
    }

And now in my Action group I get this:
image

and on hover:
image

This does look more consistent IMHO.

@malle-pietje
Copy link
Author

malle-pietje commented Aug 15, 2023

For now I've implemented a custom Action class that extends STS\FilamentImpersonate\Tables\Actions\Impersonate Filament\Tables\Actions\Action so I'm happy 😉

Thanks for this great plugin!

@jonathan-bird
Copy link

jonathan-bird commented Sep 14, 2023

Screenshot 2023-09-15 at 8 39 43 am

Just adding to this, based on Filament's defaults, I think that this possibly suits as the default values and then in the docs might be worth adding the different styles (eg button-only view, larger icon etc.)

Impersonate::make()
    ->link()
    ->iconSize(IconSize::Small)
    ->label('Login as'),

The comparison style is to Filament's pre-built actions in v3 which you may want to stay consistent with:

Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\ForceDeleteAction::make(),
Tables\Actions\RestoreAction::make()

@trippo
Copy link

trippo commented Jan 15, 2024

The actual solution is:

Impersonate::make()->grouped()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants