Refactor action menu (#7586)
Introduces effects to set the actionMenuEntries
This commit is contained in:
@ -0,0 +1,22 @@
|
||||
import { actionMenuEntriesComponentState } from '@/action-menu/states/actionMenuEntriesComponentState';
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry';
|
||||
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
|
||||
export const actionMenuEntriesComponentSelector = createComponentSelectorV2<
|
||||
ActionMenuEntry[]
|
||||
>({
|
||||
key: 'actionMenuEntriesComponentSelector',
|
||||
instanceContext: ActionMenuComponentInstanceContext,
|
||||
get:
|
||||
({ instanceId }) =>
|
||||
({ get }) =>
|
||||
Array.from(
|
||||
get(
|
||||
actionMenuEntriesComponentState.atomFamily({ instanceId }),
|
||||
).values(),
|
||||
)
|
||||
.filter(isDefined)
|
||||
.sort((a, b) => a.position - b.position),
|
||||
});
|
||||
@ -3,9 +3,9 @@ import { createComponentStateV2 } from '@/ui/utilities/state/component-state/uti
|
||||
import { ActionMenuEntry } from '../types/ActionMenuEntry';
|
||||
|
||||
export const actionMenuEntriesComponentState = createComponentStateV2<
|
||||
ActionMenuEntry[]
|
||||
Map<string, ActionMenuEntry>
|
||||
>({
|
||||
key: 'actionMenuEntriesComponentState',
|
||||
defaultValue: [],
|
||||
defaultValue: new Map(),
|
||||
componentInstanceContext: ActionMenuComponentInstanceContext,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user