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_classmethod to returnWorkItems::TypesFramework::SystemDefined::Typewhen 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::HasTypeconcern to standardize work item type handling across models - Implements
work_item_typegetter/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, andWorkItems::Statuses::Custom::Mapping
EE Feature Support:
- Updated custom field and lifecycle models to work with system-defined types
- Implemented
work_item_typesgetter/setter for custom fields and lifecycles to manage associations with system-defined types - Added
autosave: trueto associations for seamless persistence - Updated lifecycle attachment service to use provider methods
GraphQL & Services:
- Updated
WorkItems::TypesResolverto skip widget definition preloads when using system-defined types - Fixed
Issues::BuildServiceto use provider'sfetch_work_item_typemethod - Updated
Issues::BaseServiceto 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.
Related Issues
How to set up and validate locally
-
Check out the branch:
git checkout sx/integrate-system-defined-type-into-types-provider -
Enable the feature flag: In your local Rails console or via the UI, enable
work_item_system_defined_typefor the group you are planning to test - Run tests: Execute the test suite to verify the changes work correctly
-
Manual testing: In general things need to work as before, there should not be ay change. Here are some things you can try manually.
- Create/edit work items and verify they function correctly with the new system-defined types.
- Create/edit custom fields and verify that the work item types are assigned correctly
- Filter by work item type works correctly, also changing the sorting preferences for the WorkItems::UserPreference model.
- Bulk update for work items, works as expected.
- Creating a custom lifecycle for a type and also the mapping works as expected
- Quick actions for updating type, works
Edited by Stefanos Xanthopoulos