@@ -539,18 +539,19 @@ function useViewableActionConfigurations(
539539 }
540540}
541541
542+ const ALL_ACTIONS = [
543+ ...Object . values ( ActionType ) ,
544+ ...Object . values ( ClientSpecificAction )
545+ ]
546+
542547export function useUserAllowedActions ( eventType : string ) {
543548 const scopes = useSelector ( getScope )
544-
545- const actions = Object . values ( ActionType )
546- const clientSpecificActions = Object . values ( ClientSpecificAction )
547-
548549 const allowedActions = useMemo (
549550 ( ) =>
550- [ ... actions , ... clientSpecificActions ] . filter ( ( action ) =>
551+ ALL_ACTIONS . filter ( ( action ) =>
551552 isActionInScope ( scopes ?? [ ] , action , eventType )
552553 ) ,
553- [ scopes , eventType , actions , clientSpecificActions ]
554+ [ scopes , eventType ]
554555 )
555556
556557 return {
@@ -671,29 +672,31 @@ export function useAllowedActionConfigurations(
671672 openDraft
672673 )
673674
674- const availableAssignmentActions = getAvailableAssignmentActions (
675- event ,
676- authentication
677- )
678-
679- const availableEventActions = getAvailableActionsForEvent ( event )
680- const openDraftAction = openDraft ? [ openDraft . action . type ] : [ ]
681-
682- const allowedActionConfigs : ActionMenuItem [ ] = [
683- ...availableAssignmentActions ,
684- ...availableEventActions ,
685- ...openDraftAction
686- ]
687- // deduplicate after adding the draft
688- . filter ( ( action , index , self ) => self . indexOf ( action ) === index )
689- . filter (
690- ( action ) : action is ActionMenuActionType =>
691- ClientSpecificAction . REVIEW_CORRECTION_REQUEST === action ||
692- workqueueActions . safeParse ( action ) . success
675+ const allowedActionConfigs : ActionMenuItem [ ] = useMemo ( ( ) => {
676+ const availableAssignmentActions = getAvailableAssignmentActions (
677+ event ,
678+ authentication
679+ )
680+ const availableEventActions = getAvailableActionsForEvent ( event )
681+ const openDraftAction = openDraft ? [ openDraft . action . type ] : [ ]
682+ return (
683+ [
684+ ...availableAssignmentActions ,
685+ ...availableEventActions ,
686+ ...openDraftAction
687+ ]
688+ // deduplicate after adding the draft
689+ . filter ( ( action , index , self ) => self . indexOf ( action ) === index )
690+ . filter (
691+ ( action ) : action is ActionMenuActionType =>
692+ ClientSpecificAction . REVIEW_CORRECTION_REQUEST === action ||
693+ workqueueActions . safeParse ( action ) . success
694+ )
695+ . filter ( ( action ) => isActionAllowed ( action ) )
696+ // We need to transform data and filter out hidden actions to ensure hasOnlyMetaAction receives the correct values.
697+ . map ( ( a ) => ( { ...config [ a ] , type : a } ) )
693698 )
694- . filter ( ( action ) => isActionAllowed ( action ) )
695- // We need to transform data and filter out hidden actions to ensure hasOnlyMetaAction receives the correct values.
696- . map ( ( a ) => ( { ...config [ a ] , type : a } ) )
699+ } , [ openDraft , config , isActionAllowed , event , authentication ] )
697700
698701 const { customActionModal, customActionConfigs } = useCustomActionConfigs (
699702 event ,
0 commit comments