Skip to content

Feat/item actions only except#15

Merged
enoonan merged 1 commit intoenoonan:mainfrom
kepi:feat/item-actions-only-except
Jan 13, 2026
Merged

Feat/item actions only except#15
enoonan merged 1 commit intoenoonan:mainfrom
kepi:feat/item-actions-only-except

Conversation

@kepi
Copy link
Copy Markdown
Contributor

@kepi kepi commented Jan 2, 2026

Added missing support of :only and :except on item actions. Example:

item_actions do
  action :versions,
         SomeWeb.Admin.Resource,
         only: [:row]
end

@kepi kepi force-pushed the feat/item-actions-only-except branch from 88d50f6 to b419741 Compare January 2, 2026 12:05
@enoonan
Copy link
Copy Markdown
Owner

enoonan commented Jan 6, 2026

Would it be possible to narrow this PR to only focus on the :only and :except item action params? And then add tests to verify it works?

I'm uncertain about the stuff relating to the primary key. I'd need to understand your use case better. It might be more of a documentation issue.

@kepi kepi force-pushed the feat/item-actions-only-except branch from b419741 to 6b56906 Compare January 6, 2026 18:30
@kepi
Copy link
Copy Markdown
Contributor Author

kepi commented Jan 6, 2026

Sorry, I accidently based it on wrong branch with my second WIP PR. Fixed.

As for tests - TBH I don't even know where to begin. ExUnit seems similar to other test libraries I used but I'm completely oblivious to what should I test or how exactly current tests work.

If you can give me some pointers, it would definitely help. Existing test for similar functionality would be best, hopefully I can wrap my head around it.

If anyone else would volunteer to add test for this, I'll be really glad.

@enoonan
Copy link
Copy Markdown
Owner

enoonan commented Jan 6, 2026

I think you should add the tests so that you can learn to add the tests! I actually really love ExUnit and it quite frankly made me a much better TDD-er in all other stacks.

To start I'd say just explore the existing test suite as it is. To test functionality, you need to create a test Ash resource where all the other test Ash resources are (test/support/test_resources.ex), and then you need to create a test LiveResource which uses your tests resource, where all the other test LiveResources are (test/support/test_live.ex).

For this functionality you'd probably want the actual assertions to live under test/ash_backpex/live_resource/transformer_test.exs

@enoonan
Copy link
Copy Markdown
Owner

enoonan commented Jan 6, 2026

Also lmk if you'd like to start with a clean fork/PR and I can close this one out. I often find it very difficult to undo things.

@kepi kepi force-pushed the feat/item-actions-only-except branch 2 times, most recently from c2cab83 to 88653e8 Compare January 6, 2026 20:27
@kepi
Copy link
Copy Markdown
Contributor Author

kepi commented Jan 6, 2026

No need to start clean, I'm quite fluent with Git (unlike Elixir :D).

Anyway those directions was exactly what I needed. I added two test resources, one with :only and one with :except and 4 tests:

  • if :only exists when it should
  • if :except exists when it should
  • if :only doesn't exist on your original TestPromoteItemAction
  • if :except doesn't exist on TestPromoteItemActionWithOnly

Do you want any other?

Btw. I'm not really sure with naming tests but hopefully it is decent enough.

Added missing support of :only and :except on item actions. Example:

    item_actions do
      action :versions,
             SomeWeb.Admin.Resource,
             only: [:row]
    end
@kepi kepi force-pushed the feat/item-actions-only-except branch from 88653e8 to 4f5de81 Compare January 8, 2026 20:21
@kepi
Copy link
Copy Markdown
Contributor Author

kepi commented Jan 13, 2026

Is there anything else I can provide or add here to have this merged? I hope this one is just small addition without any downsides?

@enoonan enoonan merged commit fb590cb into enoonan:main Jan 13, 2026
1 check passed
@enoonan
Copy link
Copy Markdown
Owner

enoonan commented Jan 13, 2026

Merged!

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

Successfully merging this pull request may close these issues.

2 participants