Skip to content

Comments

Csv template admin set context#1119

Merged
ShanaLMoore merged 2 commits intobulkrax-v2-importerfrom
csv-template-admin-set-context
Feb 20, 2026
Merged

Csv template admin set context#1119
ShanaLMoore merged 2 commits intobulkrax-v2-importerfrom
csv-template-admin-set-context

Conversation

@ShanaLMoore
Copy link
Contributor

@ShanaLMoore ShanaLMoore commented Feb 20, 2026

Summary

When HYRAX_FLEXIBLE is enabled and the user selects an admin set that has a metadata context (e.g. from the M3 profile), the CSV template download and validation now use that context. Context-gated properties (e.g. dimensions for ImageResource in special_context) are included in the template columns and in validation instead of being omitted.

Implementation: pass admin_set_id into CSV template generation and validation; call Hyrax.schema_for(klass:, admin_set_id:) so the schema reflects the admin set’s context; update the "Download CSV template" link in the v2 importer UI so the selected admin set is in the URL.

Ticket Number

Screenshots / Video

when an admin set using a context is selected, dimensions should be included in the template:
bulkrax_template_20260220_162644.csv

When an admin set is chosen, but it does not have a context - dimensions will not be included in the template:
bulkrax_template_20260220_162559.csv

Expected Behavior

  • With HYRAX_FLEXIBLE and an admin set that has a context (e.g. special_context in the M3 profile), the downloaded CSV template includes columns for properties that are available_on that context (e.g. dimensions for ImageResource).
  • Validation uses the same context-aware schema so those columns are recognized and validated.
  • If no admin set is selected or the admin set has no context, behavior is unchanged (base schema, no context-only columns).

Sample Files

  • Profile: metadata-profile-v.5.yml with a property under available_on.context (e.g. dimensions for ImageResource in special_context).
  • A CSV exported from the new template for that admin set should include the context-specific column(s).

Notes

  • Depends on Hyrax providing Hyrax.schema_for(klass:, admin_set_id:) and the admin set resource exposing contexts when flexible metadata is enabled.

- Pass admin_set_id to CSV template generation and validation so the downloaded
  template and validation use the admin set's metadata context (HYRAX_FLEXIBLE)
- Use Hyrax.schema_for(klass:, admin_set_id:) so context-gated properties
  (e.g. dimensions for ImageResource in special_context) appear in the template
  and in validation
- Update download template link via JS to include selected admin set
- ValkyrieObjectFactory and SchemaAnalyzer use keyword args for schema_for

Co-authored-by: Cursor <cursoragent@cursor.com>
@ShanaLMoore ShanaLMoore force-pushed the csv-template-admin-set-context branch from 90bd87e to 488144a Compare February 20, 2026 16:11
@ShanaLMoore ShanaLMoore added the minor-ver for release notes label Feb 20, 2026
@ShanaLMoore ShanaLMoore requested a review from Copilot February 20, 2026 16:28
Copy link

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 enables context-aware CSV template generation and validation in Bulkrax when HYRAX_FLEXIBLE is enabled. When a user selects an admin set with a metadata context (e.g., from the M3 profile), the CSV template download and validation now include context-gated properties like dimensions for ImageResource.

Changes:

  • Pass admin_set_id parameter from the UI through the controller to the CsvValidationService for both template generation and validation
  • Update the v2 importer UI to dynamically append the selected admin set ID to the CSV template download URL
  • Add test coverage to verify admin_set_id is passed correctly to the service

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
app/controllers/bulkrax/importers_controller.rb Extracts admin_set_id from request parameters and passes it to CsvValidationService.generate_template
app/views/bulkrax/importers/new_v2.html.erb Adds id and data attribute to the download template link for JavaScript manipulation
app/assets/javascripts/bulkrax/importers_stepper.js Implements updateDownloadTemplateLink function to dynamically append admin_set_id to download URL
spec/controllers/bulkrax/importers_controller_spec.rb Adds test to verify admin_set_id parameter is passed to the service

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- In sample_csv_file spec, expect generate_template to be called with admin_set_id: nil when param is omitted
- Restore "a" in download link text: "Download a CSV template for your tenant"
@ShanaLMoore ShanaLMoore marked this pull request as ready for review February 20, 2026 16:37
Copy link
Contributor

@kirkkwang kirkkwang left a comment

Choose a reason for hiding this comment

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

Looks great!

@ShanaLMoore ShanaLMoore merged commit 904a5ad into bulkrax-v2-importer Feb 20, 2026
9 checks passed
@ShanaLMoore ShanaLMoore deleted the csv-template-admin-set-context branch February 20, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor-ver for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants