Integrate system-defined work item types into the types provider

What does this MR do and why?

This MR completes the integration of system-defined work item types into the WorkItems::TypesFramework::Provider, enabling the transition from database-backed types to code-based type definitions controlled by the work_item_system_defined_type feature flag.

Key Changes

Provider Integration:

  • Uncommented and activated feature flag checks in provider methods (unfiltered_base_types, ids_by_base_types, by_ids_with_widget_definition_preload, by_ids_ordered_by_name, by_base_types_ordered_by_name)
  • Updated type_class method to return WorkItems::TypesFramework::SystemDefined::Type when feature flag is enabled
  • Provider now seamlessly switches between system-defined and database-backed types based on feature flag state

New Concern for Type Association:

  • Created WorkItems::TypesFramework::HasType concern to standardize work item type handling across models
  • Implements work_item_type getter/setter that uses the provider to fetch types
  • Automatically handles both system-defined and custom types through the provider interface
  • Included in: Issue, WorkItems::UserPreference, WorkItems::TypeCustomField, WorkItems::TypeCustomLifecycle, and WorkItems::Statuses::Custom::Mapping

EE Feature Support:

  • Updated custom field and lifecycle models to work with system-defined types
  • Implemented work_item_types getter/setter for custom fields and lifecycles to manage associations with system-defined types
  • Added autosave: true to associations for seamless persistence
  • Updated lifecycle attachment service to use provider methods

GraphQL & Services:

  • Updated WorkItems::TypesResolver to skip widget definition preloads when using system-defined types
  • Fixed Issues::BuildService to use provider's fetch_work_item_type method
  • Updated Issues::BaseService to pass project instead of container to provider

Test Updates:

  • Updated factories and tests to use build(:work_item_system_defined_type) instead of database-backed types
  • Added comprehensive test coverage for new getter/setter methods in custom fields and lifecycles
  • Added tests for hierarchy and depth validation with system-defined types
  • Updated widget definition tests to handle both system-defined and legacy widget definitions

Backward Compatibility

All changes are protected by the work_item_system_defined_type feature flag, ensuring backward compatibility. When disabled, the system falls back to database-backed types with no behavioral changes.

How to set up and validate locally

  1. Check out the branch: git checkout sx/integrate-system-defined-type-into-types-provider
  2. Enable the feature flag: In your local Rails console or via the UI, enable work_item_system_defined_type for the group you are planning to test
  3. Run tests: Execute the test suite to verify the changes work correctly
  4. Manual testing: In general things need to work as before, there should not be ay change. Here are some things you can try manually.
    1. Create/edit work items and verify they function correctly with the new system-defined types.
    2. Create/edit custom fields and verify that the work item types are assigned correctly
    3. Filter by work item type works correctly, also changing the sorting preferences for the WorkItems::UserPreference model.
    4. Bulk update for work items, works as expected.
    5. Creating a custom lifecycle for a type and also the mapping works as expected
    6. Quick actions for updating type, works
Edited by Stefanos Xanthopoulos

Merge request reports

Loading