@@ -28,6 +28,12 @@ import { useOrbitData } from '../hoc/useOrbitData';
2828import { shallowEqual , useSelector } from 'react-redux' ;
2929import { mainSelector , sharedSelector } from '../selector' ;
3030import ProfileDialog from './ProfileDialog' ;
31+ import { useRole } from '../crud/useRole' ;
32+ import { useOrganizedBy } from '../crud' ;
33+ import {
34+ useTeamWorkflowProcess ,
35+ BOLD_WORKFLOW_PROCESS ,
36+ } from '../crud/useTeamWorkflowProcess' ;
3137
3238const TermsItem = styled ( StyledMenuItem ) < MenuItemProps > ( ( ) => ( {
3339 textAlign : 'center' ,
@@ -54,6 +60,13 @@ export function UserMenu(props: IProps) {
5460 const [ developer ] = useGlobal ( 'developer' ) ;
5561 const [ user ] = useGlobal ( 'user' ) ;
5662 const [ , setMobileView ] = useGlobal ( 'mobileView' ) ;
63+ const [ org ] = useGlobal ( 'organization' ) ;
64+ const [ addStoryOrPassage , setAddStoryOrPassage ] =
65+ useGlobal ( 'addStoryOrPassage' ) ;
66+ const { userIsAdmin } = useRole ( ) ;
67+ const { getOrganizedBy } = useOrganizedBy ( ) ;
68+ const isBoldWorkflow =
69+ useTeamWorkflowProcess ( org ) === BOLD_WORKFLOW_PROCESS ;
5770 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
5871 const [ shift , setShift ] = React . useState ( false ) ;
5972 const [ userRec , setUserRec ] = React . useState < UserD | undefined > ( undefined ) ;
@@ -94,6 +107,12 @@ export function UserMenu(props: IProps) {
94107 setAnchorEl ( null ) ;
95108 } ;
96109
110+ const handleAddStoryOrPassageToggle = ( ) => {
111+ // session-only flag; intentionally not persisted to localStorage
112+ setAddStoryOrPassage ( ! addStoryOrPassage ) ;
113+ setAnchorEl ( null ) ;
114+ } ;
115+
97116 return (
98117 < div >
99118 < IconButton
@@ -142,6 +161,23 @@ export function UserMenu(props: IProps) {
142161 < ListItemText primary = { t . mobileView } />
143162 </ StyledMenuItem >
144163 ) }
164+ { isBoldWorkflow && ! userIsAdmin && (
165+ < StyledMenuItem
166+ id = "addStoryOrPassage"
167+ onClick = { handleAddStoryOrPassageToggle }
168+ >
169+ < ListItemIcon >
170+ < Checkbox
171+ checked = { addStoryOrPassage }
172+ size = "small"
173+ sx = { { padding : 0 } }
174+ />
175+ </ ListItemIcon >
176+ < ListItemText
177+ primary = { t . addSectionOrPassage . replace ( '{0}' , getOrganizedBy ( true ) ) }
178+ />
179+ </ StyledMenuItem >
180+ ) }
145181 { shift && ! isElectron && (
146182 < StyledMenuItem id = "clearCache" onClick = { handleAction ( 'Clear' ) } >
147183 < ListItemIcon >
0 commit comments