should-show-navigation-item.ts
1 export function shouldShowNavigationItem( 2 visibilityPreferencesKey: string | null, 3 isEditing: boolean, 4 data: Record<string, boolean> | null, 5 itemVisibilityPreferenceKey: string, 6 ): boolean { 7 // If there are no visibility preferences, 8 // the item should always be shown. 9 if (!visibilityPreferencesKey) { 10 return true; 11 } 12 13 // If the visibility preference of an item 14 // is in an editing state, it should be shown. 15 if (isEditing) { 16 return true; 17 } 18 19 // Show the item if the visibility preference is to show it. 20 if (data && data[itemVisibilityPreferenceKey]) { 21 return true; 22 } 23 24 return false; 25 }