-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Refactored all single record actions #9045
Refactored all single record actions #9045
Conversation
…o-use-contextual-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements a major refactoring of single record actions to use a configuration-based approach, preparing for future database storage of action definitions.
- Added
DefaultSingleRecordActionsConfigV1.ts
andDefaultSingleRecordActionsConfigV2.ts
defining standard actions (favorites, delete) with consistent properties like type, scope, and hooks - Added
WorkflowSingleRecordActionsConfig.ts
with 8 workflow-specific actions (activate, deactivate, test, etc.) following the same configuration pattern - Introduced new action hook pattern returning
shouldBeRegistered
,onClick
, and optionalConfirmationModal
throughactionHookResult.ts
- Removed imperative action registration in favor of declarative configs, deleting files like
SingleRecordActionMenuEntrySetter.tsx
anduseManageFavoritesSingleRecordAction.ts
- Added feature flag
IS_PAGE_HEADER_V2_ENABLED
inRecordShowPage.tsx
to control new action menu vs legacy workflow headers
32 file(s) reviewed, 28 comment(s)
Edit PR Review Bot Settings | Greptile
...n-menu/actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetter.tsx
Outdated
Show resolved
Hide resolved
.../actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetterEffect.tsx
Outdated
Show resolved
Hide resolved
.../actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetterEffect.tsx
Show resolved
Hide resolved
.../actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetterEffect.tsx
Outdated
Show resolved
Hide resolved
...ction-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction.ts
Show resolved
Hide resolved
...gle-record/workflow-version-actions/hooks/useUseAsDraftWorkflowVersionSingleRecordAction.tsx
Show resolved
Hide resolved
...gle-record/workflow-version-actions/hooks/useUseAsDraftWorkflowVersionSingleRecordAction.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for your hooks. Otherwise someone else will be stuck with coverage soon :)
.../actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetterEffect.tsx
Outdated
Show resolved
Hide resolved
...on-menu/actions/record-actions/single-record/constants/DefaultSingleRecordActionsConfigV2.ts
Show resolved
Hide resolved
...ction-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction.ts
Show resolved
Hide resolved
...-menu/actions/record-actions/single-record/hooks/useRemoveFromFavoritesSingleRecordAction.ts
Show resolved
Hide resolved
...flow-version-actions/hooks/useSeeWorkflowVersionsHistoryWorkflowVersionSingleRecordAction.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it functionnally but the code looks great, love the approach
Please put back some tests!
…o-use-contextual-actions
Context
Refactored all single record actions so they can be defined by a config file.
This refactoring is made with the idea that later the actions will be stored in the database, so we needed a way to serialize them.
For each object we can define a config file, if an object has no config file, it falls back to the default config.
I introduced action hooks, which return:
shouldBeRegistered
:boolean
Whether the action should be registered.onClick
:() => void
The code that will be executed when we click on an actionConfirmationModal
?:React.ReactNode
(optional) The confirmation modal which will be displayed on clickThis PR also closes #8973
Next steps