@@ -195,11 +195,25 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
195195 } ;
196196 } , [ checkScroll ] ) ;
197197
198+ const {
199+ isCloudUser,
200+ isEnterpriseSelfHostedUser,
201+ isCommunityUser,
202+ isCommunityEnterpriseUser,
203+ } = useGetTenantLicense ( ) ;
204+
205+ const [ licenseTag , setLicenseTag ] = useState ( '' ) ;
206+ const isAdmin = user . role === USER_ROLES . ADMIN ;
207+ const isEditor = user . role === USER_ROLES . EDITOR ;
208+
198209 useEffect ( ( ) => {
199210 const navShortcuts = ( userPreferences ?. find (
200211 ( preference ) => preference . name === USER_PREFERENCES . NAV_SHORTCUTS ,
201212 ) ?. value as unknown ) as string [ ] ;
202213
214+ const shouldShowIntegrations =
215+ ( isCloudUser || isEnterpriseSelfHostedUser ) && ( isAdmin || isEditor ) ;
216+
203217 if ( navShortcuts && isArray ( navShortcuts ) && navShortcuts . length > 0 ) {
204218 // nav shortcuts is array of strings
205219 const pinnedItems = navShortcuts
@@ -211,11 +225,14 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
211225 // Set pinned items in the order they were stored
212226 setPinnedMenuItems ( pinnedItems ) ;
213227
214- // Set secondary items with proper isPinned state
215228 setSecondaryMenuItems (
216229 defaultMoreMenuItems . map ( ( item ) => ( {
217230 ...item ,
218231 isPinned : pinnedItems . some ( ( pinned ) => pinned . itemKey === item . itemKey ) ,
232+ isEnabled :
233+ item . key === ROUTES . INTEGRATIONS
234+ ? shouldShowIntegrations
235+ : item . isEnabled ,
219236 } ) ) ,
220237 ) ;
221238 } else {
@@ -225,17 +242,26 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
225242 ) ;
226243 setPinnedMenuItems ( defaultPinnedItems ) ;
227244
228- // Set secondary items with proper isPinned state
229245 setSecondaryMenuItems (
230246 defaultMoreMenuItems . map ( ( item ) => ( {
231247 ...item ,
232248 isPinned : defaultPinnedItems . some (
233249 ( pinned ) => pinned . itemKey === item . itemKey ,
234250 ) ,
251+ isEnabled :
252+ item . key === ROUTES . INTEGRATIONS
253+ ? shouldShowIntegrations
254+ : item . isEnabled ,
235255 } ) ) ,
236256 ) ;
237257 }
238- } , [ userPreferences ] ) ;
258+ } , [
259+ userPreferences ,
260+ isCloudUser ,
261+ isEnterpriseSelfHostedUser ,
262+ isAdmin ,
263+ isEditor ,
264+ ] ) ;
239265
240266 const isOnboardingV3Enabled = featureFlags ?. find (
241267 ( flag ) => flag . name === FeatureKeys . ONBOARDING_V3 ,
@@ -249,10 +275,6 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
249275 ( flag ) => flag . name === FeatureKeys . PREMIUM_SUPPORT ,
250276 ) ?. active ;
251277
252- const [ licenseTag , setLicenseTag ] = useState ( '' ) ;
253- const isAdmin = user . role === USER_ROLES . ADMIN ;
254- const isEditor = user . role === USER_ROLES . EDITOR ;
255-
256278 const userSettingsMenuItem = {
257279 key : ROUTES . SETTINGS ,
258280 label : 'Settings' ,
@@ -375,13 +397,6 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
375397
376398 const { registerShortcut, deregisterShortcut } = useKeyboardHotkeys ( ) ;
377399
378- const {
379- isCloudUser,
380- isEnterpriseSelfHostedUser,
381- isCommunityUser,
382- isCommunityEnterpriseUser,
383- } = useGetTenantLicense ( ) ;
384-
385400 const isWorkspaceBlocked = trialInfo ?. workSpaceBlock || false ;
386401
387402 const openInNewTab = ( path : string ) : void => {
@@ -718,28 +733,6 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
718733 }
719734 } ;
720735
721- useEffect ( ( ) => {
722- if ( ( isCloudUser || isEnterpriseSelfHostedUser ) && ( isAdmin || isEditor ) ) {
723- // enable integrations for cloud users
724- setSecondaryMenuItems ( ( prevItems ) =>
725- prevItems . map ( ( item ) => ( {
726- ...item ,
727- isEnabled : item . key === ROUTES . INTEGRATIONS ? true : item . isEnabled ,
728- } ) ) ,
729- ) ;
730-
731- // enable integrations for pinned menu items
732- // eslint-disable-next-line sonarjs/no-identical-functions
733- setPinnedMenuItems ( ( prevItems ) =>
734- prevItems . map ( ( item ) => ( {
735- ...item ,
736- isEnabled : item . key === ROUTES . INTEGRATIONS ? true : item . isEnabled ,
737- } ) ) ,
738- ) ;
739- }
740- // eslint-disable-next-line react-hooks/exhaustive-deps
741- } , [ isCloudUser , isEnterpriseSelfHostedUser ] ) ;
742-
743736 const onClickVersionHandler = useCallback ( ( ) : void => {
744737 if ( isCloudUser ) {
745738 return ;
0 commit comments