Skip to content

Conversation

@krns
Copy link
Member

@krns krns commented Jul 2, 2025

Todos

  • Align ash adapter with changes

Copy link
Member Author

@krns krns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also checked insert and update and noticed that update already gets the fields passed, insert does not. Is that on purpose?

def insert(item, attrs, assigns, live_resource, opts) do
def update(item, attrs, fields, assigns, live_resource, opts \\ [])

@krns krns requested review from Flo0807 and pehbehbeh and removed request for pehbehbeh July 2, 2025 12:52
@Flo0807 Flo0807 assigned Flo0807 and unassigned krns Sep 5, 2025
@Flo0807 Flo0807 added breaking-change A breaking change and removed enhancement Changes that are not breaking labels Sep 5, 2025
@Flo0807 Flo0807 changed the title Use filtered fields in ecto adapter Refactor fields handling Sep 5, 2025
@Flo0807 Flo0807 marked this pull request as ready for review September 5, 2025 13:04
Copilot AI review requested due to automatic review settings September 5, 2025 13:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors fields handling in Backpex by introducing a new centralized fields/3 function that combines field validation, action-based filtering, and permission-based filtering into a single operation. The refactoring updates the resource and adapter APIs to pass fields as an explicit parameter rather than computing them multiple times throughout the codebase.

Key changes:

  • Replaced validated_fields/1 with fields/3 that handles validation, action filtering, and permission checking
  • Updated Resource and Adapter function signatures to include fields parameter
  • Simplified field access patterns across LiveResource modules
  • Removed :resource_action from field visibility options

Reviewed Changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/backpex/resource.ex Updated function signatures to accept fields parameter and removed internal field computation
lib/backpex/live_resource.ex Added new fields/3 function and refactored field filtering logic
lib/backpex/live_resource/show.ex Simplified field assignment using new centralized approach
lib/backpex/live_resource/index.ex Updated to use pre-computed fields from assigns
lib/backpex/live_resource/form.ex Removed duplicate field assignment logic
lib/backpex/adapters/ecto.ex Updated adapter functions to accept fields parameter
lib/backpex/adapters/ash.ex Updated adapter functions to accept fields parameter
lib/backpex/adapter.ex Enhanced callback documentation with proper type specifications
Comments suppressed due to low confidence (1)

lib/backpex/resource.ex:1

  • The parameters are in the wrong order. According to the function signature at line 265, it should be Resource.update(item, params, fields, socket.assigns, live_resource, opts) but here socket.assigns and fields are swapped.
defmodule Backpex.Resource do

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Flo0807 Flo0807 merged commit 1873e89 into develop Sep 5, 2025
6 checks passed
@Flo0807 Flo0807 deleted the feature/use-filtered-fields-in-ecto-adapter branch September 5, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change A breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants