Giter Club home page Giter Club logo

Comments (11)

saade avatar saade commented on May 28, 2024 2

wtf, i've acidentally edited your comment instead of adding a new one. sorry.

You cannot pass the $record instance as a third parameter, because it does not exist

@ousid I think the function definition is outdated?
https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Testing/TestsActions.php#L575

I may be wrong, i'm not too much into tests, i'm source diving rn to help you. Just wanted to correct the comment from @dmitry-udod

from filament.

dmitry-udod avatar dmitry-udod commented on May 28, 2024 1

@ousid Hi! Yes, the bug is indeed present, but only in tests. Seems it's happen because you use $record variable name and this is like a reserved word here

But you can avoid this bug to change code from:

->actions([
...
    Tables\Actions\EditAction::make()
        ->url(
            fn (Model $record) => 'https://filamentphp.com'
        ),
...
]),

To

->actions([
...
    Tables\Actions\EditAction::make()
        ->url(
            fn (User $user) => 'https://filamentphp.com'
        ),
...
]),
Screencast.2024-04-18.14.31.03.mp4

from filament.

saade avatar saade commented on May 28, 2024 1

But you can avoid this bug to change code from: ...

Changing Model $record to User $user would break the application if the closure needs the record. $record is a named evaluation parameter, if renamed, it would never be resolved, thats why the error is gone.

@ousid, you need to pass the $record as the third parameter to assertTableActionHasUrl()

from filament.

dmitry-udod avatar dmitry-udod commented on May 28, 2024 1

wtf, i've acidentally edited your comment instead of adding a new one. sorry.

You cannot pass the $record instance as a third parameter, because it does not exist

@ousid I think the function definition is outdated? https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Testing/TestsActions.php#L575

I may be wrong, i'm not too much into tests, i'm source diving rn to help you. Just wanted to correct the comment from @dmitry-udod

Oh. Thanks for catching that!

from filament.

saade avatar saade commented on May 28, 2024 1

The only things remain, is why the .stub didn't get updated? Or I'm missing something?

It can happen, maybe a conflicted merge result or something.

from filament.

ousid avatar ousid commented on May 28, 2024 1

The only things remain, is why the .stub didn't get updated? Or I'm missing something?

It can happen, maybe a conflicted merge result or something.

I was thinking about closing this issue (since it's not an issue anymore) But I'll keep it open for this reason, till the maintainers decided how to resolve this one.

I'll be happy to open a PR to update the .stubs file, if you want me to!

Note: Even the docs, missing this part (https://filamentphp.com/docs/3.x/tables/testing#url)

from filament.

saade avatar saade commented on May 28, 2024 1

Go for it!

from filament.

ousid avatar ousid commented on May 28, 2024

@ousid Hi! Yes, the bug is indeed present, but only in tests. Seems it's happen because you use $record variable name and this is like a reserved word here

But you can avoid this bug to change code from:

->actions([
...
    Tables\Actions\EditAction::make()
        ->url(
            fn (Model $record) => 'https://filamentphp.com'
        ),
...
]),

To

->actions([
...
    Tables\Actions\EditAction::make()
        ->url(
            fn (User $user) => 'https://filamentphp.com'
        ),
...
]),

Screencast.2024-04-18.14.31.03.mp4

Yes, the error is gone, but the example here, is just for demonstrating the shown error, in the real app, I'm developing, I need to pass the record var, as it is, to get the actual data. It's like something like this:

EditAction::make()
    ->color('success')
    ->url(
        fn (?Article $record) => route('articles.edit', $record?->getSlug())
    ),

PS: I'm using the tables package outside the panel.

from filament.

ousid avatar ousid commented on May 28, 2024

@ousid, you need to pass the $record as the third parameter to assertTableActionHasUrl()

You cannot pass the $record instance as a third parameter, because it does not exist

https://github.com/filamentphp/filament/blob/3.x/packages/tables/.stubs.php#L100

from filament.

ousid avatar ousid commented on May 28, 2024

@saade

wtf, i've acidentally edited your comment instead of adding a new one. sorry.

No worries, It happens

@ousid I think the function definition is outdated?

Not sure, will try it out, and let you know. I'm using the latest release, tho.

Update

Yes, you are right. I passed the model, and the test passes.

The only things remain, is why the .stub didn't get updated? Or I'm missing something?

from filament.

danharrin avatar danharrin commented on May 28, 2024

Please open a PR to make the stubs consistent if you wish

from filament.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.