Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata Templates Selection UI #914

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open

Conversation

joshsadam
Copy link
Contributor

@joshsadam joshsadam commented Jan 24, 2025

What does this PR do and why?

Describe in detail what your merge request does and why.

  1. Updated the ability to display none or all metadata fields via a new select input
  2. Added the ability to select existing metadata templates via the same select dropdown

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In the user interface, login as [email protected] and create a new project
  2. Create a couple new samples in the project and add some metadata fields (e.g. a, b, c)
  3. Go into the rails console;
  4. Get the user: user = User.find_by(email: "[email protected]")
  5. Get the namespace for the project you created: namespace = Project.last.namespace
  6. Create a new metadata template inside the project namespace: template = MetadataTemplates::CreateService.new(user, namespace, {name: "template1", fields: ['b', 'c']}).execute
  7. Back inside the user interface, you should be able to go to the samples page for the project you created, and from the select above the table select either: all fields, no fields, or a template.

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

@joshsadam joshsadam self-assigned this Jan 24, 2025
@joshsadam joshsadam added the enhancement New feature or request label Jan 28, 2025
@joshsadam joshsadam force-pushed the metadata-templates/dropdown branch 3 times, most recently from 7cc8fc8 to 3c4f208 Compare January 31, 2025 01:42
@joshsadam joshsadam marked this pull request as ready for review January 31, 2025 01:56
@joshsadam joshsadam force-pushed the metadata-templates/dropdown branch from 8073a23 to e97b192 Compare February 3, 2025 13:59
…thorization checks

- Added `create_metadata_template?` method to `GroupPolicy` and `ProjectNamespacePolicy` for authorization.
- Removed the obsolete `MetadataTemplatePolicy` class.
- Enhanced `CreateService` to include authorization logic for creating metadata templates.
- Updated locale files to include new activity messages for metadata template creation.
…ndling

- Introduced parameter validation in CreateService to ensure required fields are present before creating a metadata template.
- Added custom error handling for missing name and fields, improving user feedback during template creation.
- Updated tests to cover new validation scenarios, ensuring robust functionality for metadata template creation.
- Standardized quotation marks in locale files for consistency across English and French translations.
…ror handling and validation

- Initialized @metadata_template to streamline template creation process.
- Simplified error handling by directly adding errors to the namespace instead of the template.
- Refined parameter validation to ensure required fields are checked before template creation.
- Updated tests to reflect changes in error handling and validation logic, ensuring robust functionality.
- Added support for displaying metadata template creation activities in both group and project activity components.
- Introduced a new method `metadata_template_link` in the activity components to check for metadata template creation actions.
- Updated HTML templates to render appropriate translations for metadata template activities, ensuring user clarity.
- Refactored locale files to standardize the use of `template_name` in activity messages for consistency across English and French translations.
- Improved parameter handling in the `track_activity` concern to include metadata template details during activity tracking.
… error handling

- Updated CreateService to enforce validation rules ensuring fields are either present as an array or raise appropriate errors.
- Enhanced error messages in locale files for better user feedback during template creation.
- Added tests to cover scenarios for missing fields, unauthorized access, and duplicate template names, ensuring robust functionality.
- Standardized quotation marks in locale files for consistency across English and French translations.
…ncements

- Added a new `DestroyService` for handling the destruction of metadata templates, including authorization checks.
- Updated `ProjectNamespacePolicy` to include `destroy_metadata_template?` method for permission validation.
- Enhanced tests for both the `DestroyService` and `ProjectNamespacePolicy` to ensure correct permission handling and functionality.
- Improved clarity in policy and service interactions for better maintainability and user feedback.
- Refactored `create_metadata_template?` and `destroy_metadata_template?` methods to use effective access level checks for authorization.
- Updated tests to include assertions for the new permission methods, ensuring proper functionality and coverage.
- Improved clarity in permission handling for metadata template operations.
…ermissions

- Introduced `UpdateService` for handling updates to metadata templates, including authorization checks.
- Added `update_metadata_template?` method to `GroupPolicy` and `ProjectNamespacePolicy` for permission validation.
- Updated activity components to recognize metadata template update actions.
- Enhanced locale files to include new activity messages for metadata template updates.
- Added tests for `UpdateService` to ensure correct functionality and permission handling.
…a templates

- Eliminated the `validate_params` method from the `UpdateService`, simplifying the update process.
- Streamlined the execution flow by directly handling updates without pre-validation of parameters.
- Maintained authorization checks to ensure proper permissions during metadata template updates.
- Changed the update method to use `update!` for better error management during metadata template updates.
- Updated error handling to capture `ActiveRecord::RecordInvalid` exceptions and add relevant error messages to the template.
- Modified tests to reflect the new error handling behavior, ensuring accurate assertions for invalid update scenarios.
…mplate updates

- Fixed a typo in the test description for invalid parameter updates.
- Updated the test for numerical fields to assert specific error messages returned by the metadata template, ensuring accurate validation feedback.
- Improved clarity and accuracy in test cases related to metadata template updates.
- Changed the save method in CreateService to use `save!` for better error management.
- Added new validation error messages for the `name` attribute in both English and French locale files.
- Updated tests to assert the presence of specific error messages for invalid metadata template creation scenarios, ensuring accurate feedback for users.
- Refactored methods to modularize the addition of sample activity and metadata template parameters.
- Replaced conditional merges with dedicated methods for clarity and maintainability.
- Introduced a new method to handle bulk sample parameters for 'sample_destroy_multiple' action.
- Improved overall readability and structure of the parameter handling logic.
- Eliminated redundant blank lines in the `create_service.rb` file to improve code readability.
- Ensured that the file maintains a clean and consistent formatting style.
…services

- Changed the save method in CreateService to use `save` instead of `save!`, raising a custom error with detailed messages on failure.
- Updated the update method in UpdateService to use `update` instead of `update!`, removing the rescue block for `ActiveRecord::RecordInvalid`.
- Adjusted tests to reflect the new error handling logic, ensuring accurate assertions for invalid metadata template creation scenarios.
…wn component

Remove unnecessary `puts` debugging output in the component initialization method, improving code cleanliness and removing potential performance overhead
Update en.yml and fr.yml to use consistent single quotes for string values, improving code readability and maintaining a uniform style across localization files
Remove unnecessary metadata toggle label translations from both English and French locale files, cleaning up unused localization entries
Remove unused `fields_for_namespace` method and update `WorkflowExecutions::SubmissionsController` to use `fields_for_namespace_or_template`
Modify system test to assert the presence of the metadata template select dropdown instead of the import metadata button
Replace metadata toggle label click with select dropdown interaction in system tests, ensuring consistent test coverage for the new metadata template selection method
Replace metadata toggle label click with select dropdown interaction across multiple test scenarios, ensuring consistent test coverage for the new metadata template selection method
Modify system test to replace metadata toggle label click with select dropdown interaction, ensuring consistent test coverage for the new metadata template selection method
Modify system test to change metadata template dropdown selection from 'all' to 'none' and remove redundant selection steps
Update system test to select 'none' in the metadata template dropdown instead of 'all', maintaining test coverage for dropdown interaction
Add a collection route `get :list` to metadata_templates resources for both group and project route configurations
@joshsadam joshsadam force-pushed the metadata-templates/dropdown branch from 4a909a6 to ca0df4a Compare February 5, 2025 12:30
- Update metadata template dropdown to use shared partial and URL generation
- Modify localization keys for metadata template fields
- Add new shared metadata templates list view
- Adjust samples controller and views to support new dropdown approach
- Correct localization key for metadata template fields
- Add margin class to metadata template dropdown button
- Simplify metadata template handling in samples controllers
…asses

- Refactor button styling to use Tailwind utility classes
- Add responsive width and improved visual states
- Maintain dark mode compatibility
- Preserve existing dropdown functionality
…tion

- Extract metadata template list view methods into separate helper methods
- Add section headers for metadata fields and templates in dropdown
- Update localization keys to provide clearer labels
- Enhance dropdown view with conditional rendering and improved structure
- Add loading spinner for metadata templates
- Enhance dropdown button with label and increased offset
- Add hover states to metadata template list items
- Improve visual hierarchy and interaction design
- Modify 'none' and 'all' labels in English and French localization files
- Swap order of 'none' and 'all' keys in metadata template fields section
- Ensure consistent localization for metadata template dropdown
- Add new localization key for metadata template dropdown label in English and French
- Update metadata template dropdown to use translated label
- Remove hardcoded "Metadata Templates" text in dropdown partial
- Replace blue color classes with primary color classes
- Maintain consistent styling for radio buttons in metadata templates list
- Preserve dark mode and focus ring compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant