refactor: Move shared helpers & hooks from workflow-history to workflow-history-v2#1190
Conversation
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the workflow-history-v2 module to be more self-contained by moving shared types and helper functions from the workflow-history module into workflow-history-v2. The changes involve renaming types for clarity (e.g., WorkflowHistoryEventFilteringType to EventGroupCategory) and relocating filter helpers, hooks, and configuration files to avoid cross-module dependencies.
Changes:
- Moved and renamed filter helper functions (
filterGroupsByStatus,filterGroupsByCategory) from workflow-history to workflow-history-v2 - Moved
useInitialSelectedEventhook and its types to workflow-history-v2 - Created new type definitions (
EventGroupCategory,EventGroupCategoryColors, etc.) in workflow-history-filters-menu.types.ts - Renamed configuration files to use "event-group-category" naming convention
- Added comprehensive test coverage for the migrated helpers and hooks
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| workflow-history-v2.types.ts | Removed unused WorkflowHistoryEventFilteringTypeColors type |
| workflow-history-v2.tsx | Updated imports to use local filter helpers instead of importing from workflow-history module |
| workflow-history-ungrouped-event/workflow-history-ungrouped-event.tsx | Updated import to use renamed color config file |
| workflow-history-ungrouped-event/workflow-history-ungrouped-event.styles.ts | Updated import to use renamed color config file |
| workflow-history-timeline/workflow-history-timeline.tsx | Updated import to use renamed color config file |
| workflow-history-navigation-bar-events-menu/workflow-history-navigation-bar-events-menu.tsx | Updated import to use renamed color config file |
| workflow-history-filters-menu/workflow-history-filters-menu.types.ts | Added new type definitions for event group categories and statuses |
| workflow-history-filters-menu/helpers/filter-groups-by-status.ts | New file: migrated filter function with updated types |
| workflow-history-filters-menu/helpers/filter-groups-by-category.ts | New file: migrated filter function with updated types |
| workflow-history-filters-menu/helpers/tests/filter-groups-by-status.test.ts | New test file for status filter helper |
| workflow-history-filters-menu/helpers/tests/filter-groups-by-category.test.ts | New test file for category filter helper |
| workflow-history-event-group/workflow-history-event-group.tsx | Updated import to use renamed color config file |
| workflow-history-event-group/workflow-history-event-group.styles.ts | Updated import to use renamed color config file |
| workflow-history-event-group/helpers/get-event-group-filtering-type.ts | Updated to use local types and config instead of importing from workflow-history |
| workflow-history-event-group/helpers/tests/get-event-group-filtering-type.test.ts | Updated mock path to use local config file |
| hooks/use-initial-selected-event.types.ts | New file: type definitions for the migrated hook |
| hooks/use-initial-selected-event.ts | New file: migrated hook from workflow-history |
| hooks/tests/use-initial-selected-event.test.ts | New comprehensive test file for the migrated hook |
| config/workflow-history-filters.config.ts | Updated to use local filter helpers and types |
| config/workflow-history-filters-type-options.config.ts | Updated to use local types and renamed color config |
| config/workflow-history-event-group-category-filters.config.ts | New file: renamed and migrated from workflow-history-filters-type.config |
| config/workflow-history-event-group-category-colors.config.ts | Renamed file: updated to use local types |
| fixtures/workflow-history-event-groups.ts | New file: mock event groups for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/views/workflow-history-v2/hooks/use-initial-selected-event.ts
Outdated
Show resolved
Hide resolved
...history-v2/workflow-history-filters-menu/helpers/__tests__/filter-groups-by-category.test.ts
Outdated
Show resolved
Hide resolved
...history-v2/workflow-history-filters-menu/helpers/__tests__/filter-groups-by-category.test.ts
Outdated
Show resolved
Hide resolved
...history-v2/workflow-history-filters-menu/helpers/__tests__/filter-groups-by-category.test.ts
Outdated
Show resolved
Hide resolved
...iews/workflow-history-v2/workflow-history-event-group/workflow-history-event-group.styles.ts
Outdated
Show resolved
Hide resolved
...kflow-history-v2/workflow-history-ungrouped-event/workflow-history-ungrouped-event.styles.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/views/workflow-history-v2/workflow-history-event-group/helpers/tests/get-event-group-filtering-type.test.ts:33
- This Jest mock doesn’t match the module’s default export shape.
workflow-history-event-group-category-filters.configexports adefault, but the mock returns the config object at the top level, which can make the default importundefineddepending on Jest/TS interop. Update the mock to return{ __esModule: true, default: { ... } }(like the other tests in this PR).
jest.mock(
'@/views/workflow-history-v2/config/workflow-history-event-group-category-filters.config',
() => ({
ACTIVITY: 'Activity',
CHILDWORKFLOW: 'ChildWorkflowExecution',
DECISION: 'Decision',
TIMER: 'Timer',
SIGNAL: jest.fn(
(g) =>
g.groupType === 'SignalExternalWorkflowExecution' ||
g.events[0].attributes === 'workflowExecutionSignaledEventAttributes'
),
WORKFLOW: jest.fn(
(g) =>
g.groupType === 'RequestCancelExternalWorkflowExecution' ||
(g.groupType === 'Event' &&
g.events[0].attributes !== 'workflowExecutionSignaledEventAttributes')
),
})
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const groupId = initialEventGroupEntry[0]; | ||
| // If group index has not changed do not search again | ||
| if ( | ||
| foundGroupIndexRef.current && |
There was a problem hiding this comment.
foundGroupIndexRef.current is used as a truthy check here; if the found index is 0, this condition is skipped and the hook will re-scan filteredEventGroupsEntries on every render. Use an explicit foundGroupIndexRef.current !== undefined (or != null) check so index 0 is cached correctly.
| foundGroupIndexRef.current && | |
| foundGroupIndexRef.current !== undefined && |
Summary
This PR moves the filtering helpers and useInitialSelectedEvent from workflow-history to workflow-history-v2, to let them use the new types and prevent type errors when new event group types are introduced. The type WorkflowHistoryEventGroupFilteringType is also renamed to EventGroupCategory for clarity.
Test plan
Builds passing + ran locally to sanity-check.
Before (testing with a mock group type)
After (no type errors)