feat(submaps tabs): open submap on click
Description
In this PR I introduced changes to SubmapsDrawer and MapNavigation. Idea is to allow user switch easily between submaps.
Things done:
- open submap from drawer
- allow switch between the maps (tabs in top navigation)
More details about functionality
- If map is not opened yet -> open it and set as currently active
- If map is already opened -> set it as currently active
- To set map as active it modifies current
modelId
inmap reducer
Things not done
- Maps don't currently remember last position set by user
Merge request reports
Activity
requested review from @AdrianOrlow and @MateuszBolewski
added 1 commit
- 7790e460 - feat(main map tab auto set id): set main map id automaticly, added missing tests to submaps drawer
- Resolved by Tadeusz Miesiąc
20 27 // TODO to discuss manage state of failure 21 28 }); 22 29 }; 30 31 export const setActiveMapReducer = (state: MapState, action: SetActiveMapAction): void => { 32 state.data.modelId = action.payload.modelId; 33 }; - Comment on lines +31 to +33
21 28 }); 22 29 }; 30 31 export const setActiveMapReducer = (state: MapState, action: SetActiveMapAction): void => { 32 state.data.modelId = action.payload.modelId; 33 }; 34 35 export const openMapAndSetActiveReducer = ( 36 state: MapState, 37 action: OpenMapAndSetActiveAction, 38 ): void => { 39 state.data.openedMaps.push({ 40 modelId: action.payload.modelId, 41 modelName: action.payload.modelName, 42 lastPosition: { x: 0, y: 0, z: 0 }, 43 }); @teoMiesiac yep
35 export const openMapAndSetActiveReducer = ( 36 state: MapState, 37 action: OpenMapAndSetActiveAction, 38 ): void => { 39 state.data.openedMaps.push({ 40 modelId: action.payload.modelId, 41 modelName: action.payload.modelName, 42 lastPosition: { x: 0, y: 0, z: 0 }, 43 }); 44 state.data.modelId = action.payload.modelId; 45 }; 46 47 export const closeMapReducer = (state: MapState, action: CloseMapAction): void => { 48 state.data.openedMaps = state.data.openedMaps.filter( 49 openedMap => openedMap.modelId !== action.payload.modelId, 50 ); - Comment on lines +48 to +50
Scenario below is an issue:
-
User opens map id=54 => it's added to
openedMaps
array ANDmodelId
is set to 54 -
User closes map id=54 => it's removed from
openedMaps
BUTmodelId
is NOT changed
so in case of closing the map, it'll probably stay opened for the user. Or am I wrong?
This case is covered in
closeMapAndSetMainMapActiveReducer
but in this case - why there are two different reducers will completely different side effects? -
I decided to move handling this logic to components: !47 (diffs) Imo making this kind of checks in reducer would only clutter it.
added 7 commits
-
4a1c589a...8260206f - 5 commits from branch
development
- 2ac4e50f - Merge branch 'development' into feature/MIN-123-open-submaps-from-list
- 8292e62c - feat(submaps): saving position on tab switch
-
4a1c589a...8260206f - 5 commits from branch
57 }); 58 59 const mainMapButton = screen.getByRole('button', { name: 'Main map' }); 60 const mainMapCloseButton = await within(mainMapButton).queryByTestId('close-icon'); 61 expect(mainMapCloseButton).not.toBeInTheDocument(); 62 63 const histamineMapButton = screen.getByRole('button', { name: 'Histamine signaling' }); 64 const histamineMapCloseButton = await within(histamineMapButton).getByTestId('close-icon'); 65 expect(histamineMapCloseButton).toBeInTheDocument(); 66 67 const prknMapButton = screen.getByRole('button', { name: 'PRKN substrates' }); 68 const prknMapCloseButton = await within(prknMapButton).getByTestId('close-icon'); 69 expect(prknMapCloseButton).toBeInTheDocument(); 70 }); 71 72 it('should close map tab when clicking on close button while', async () => { mentioned in commit ea558ff3