ash-project / ash_admin

A super-admin UI dashboard for Ash Framework applications, built with Phoenix LiveView.
https://hexdocs.pm/ash_admin
MIT License
106 stars 48 forks source link

fix: loading multiple relationships with the same destination resourc… #98

Closed arianics closed 8 months ago

arianics commented 8 months ago

…e that has sensitive fields

Duplicate ID error is raised when a resource with sensitive attributes is present more than once on admin pages.

** (RuntimeError) found duplicate ID "a9f8b9fe-c1be-471e-b7c6-973cc1152e15-history" for component AshAdmin.Components.Resource.SensitiveAttribute when rendering template

please let me know if there's better way of doing this.

Contributor checklist

zachdaniel commented 8 months ago

This is good :) There is another issue here though which is that it is hard-coded record.id, which means it will blow up for any records without an id! Not great. I'll merge this, as this looks like a good fix to the issue you found, but we'll need to encode the actual primary key of the record to avoid the issue.

zachdaniel commented 8 months ago

🚀 Thank you for your contribution! 🚀

vonagam commented 8 months ago

I would also assume that the same fix needs to be applied for attribute with type of Ash.Type.Map.

zachdaniel commented 8 months ago

Yep, and that line you linked to there actually has the fix for the record.id: AshAdmin.Helpers.encode_primary_key(@record). @vonagam I'm busy for the next few hours/this evening, do you have a few to make that PR? Thank you as always for your attention to detail!

vonagam commented 8 months ago

Oh, busy myself and don't have much experience with AshAdmin yet (don't have it setup for contributing)... But my 5c for future: this and this need updating. Those will be relevant for relationships of cardinality one (for cardinality many this PR should have fixed it, but yeah, need to use different thing for id).

zachdaniel commented 8 months ago

No problem, I'll take care of it! Thanks for pointing it out :)