690 extract shouldberegistered from the useaction hooks (#11355)
Closes https://github.com/twentyhq/core-team-issues/issues/690 This PR is the first part of a refactoring on the actions system https://github.com/twentyhq/core-team-issues/issues/683. It: - Removes `shouldBeRegistered` from the useAction hook - Instead `shouldBeRegistered` becomes a function to which we can pass parameters which describe the context of the app (the object, the selected record, information about favorites ...). It returns a boolean. - `useShouldActionBeRegisteredParams` returns the parameters to pass to the `shouldBeRegistered` - Introduces a way to inherit actions from the default config and to overwrite its properties, closing https://github.com/twentyhq/core-team-issues/issues/72 Some tests testing if an action was registered correctly have been removed, we should add them back at the end of the global refactoring.
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { RecordActionMenuEntriesSetter } from '@/action-menu/actions/record-actions/components/RecordActionMenuEntriesSetter';
|
||||
import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey';
|
||||
import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKeys';
|
||||
import { RecordAgnosticActionMenuEntriesSetter } from '@/action-menu/actions/record-agnostic-actions/components/RecordAgnosticActionMenuEntriesSetter';
|
||||
import { RunWorkflowRecordAgnosticActionMenuEntriesSetter } from '@/action-menu/actions/record-agnostic-actions/components/RunWorkflowRecordAgnosticActionMenuEntriesSetter';
|
||||
import { RecordAgnosticActionsKey } from '@/action-menu/actions/record-agnostic-actions/types/RecordAgnosticActionsKey';
|
||||
import { RecordAgnosticActionsKeys } from '@/action-menu/actions/record-agnostic-actions/types/RecordAgnosticActionsKeys';
|
||||
import { ActionMenuConfirmationModals } from '@/action-menu/components/ActionMenuConfirmationModals';
|
||||
import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
@ -144,16 +144,16 @@ export const CommandMenuContainer = ({
|
||||
isInRightDrawer: true,
|
||||
onActionExecutedCallback: ({ key }) => {
|
||||
if (
|
||||
key !== RecordAgnosticActionsKey.SEARCH_RECORDS &&
|
||||
key !== RecordAgnosticActionsKeys.SEARCH_RECORDS &&
|
||||
key !==
|
||||
RecordAgnosticActionsKey.SEARCH_RECORDS_FALLBACK &&
|
||||
RecordAgnosticActionsKeys.SEARCH_RECORDS_FALLBACK &&
|
||||
key !== NoSelectionRecordActionKeys.CREATE_NEW_RECORD
|
||||
) {
|
||||
toggleCommandMenu();
|
||||
}
|
||||
|
||||
if (
|
||||
key !== RecordAgnosticActionsKey.SEARCH_RECORDS_FALLBACK
|
||||
key !== RecordAgnosticActionsKeys.SEARCH_RECORDS_FALLBACK
|
||||
) {
|
||||
setCommandMenuSearch('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user