fix: 🐛 set current viewport as active when switching layouts (#1018)

* fix: 🐛 set current viewport as active when switching layouts

check if current viewport index is less than the current layout lenght
and set 0 if so or keep current selected cell index as active viewport

Closes: 999

* chore: 🤖 commenting out docker layer caching in the short-term

commenting out docker layer caching in the short-term

* refactor: 💡 refactor layout matrix index conditional
This commit is contained in:
Igor Octaviano 2019-10-09 16:37:26 -03:00 committed by Danny Brown
parent a28984ef1f
commit 2a743554b6
2 changed files with 14 additions and 8 deletions

View File

@ -142,8 +142,8 @@ jobs:
steps:
- attach_workspace:
at: ~/repo
- setup_remote_docker:
docker_layer_caching: true
# - setup_remote_docker:
# docker_layer_caching: true
- run:
name: Build and push Docker image
command: |
@ -198,8 +198,8 @@ jobs:
steps:
- attach_workspace:
at: ~/repo
- setup_remote_docker:
docker_layer_caching: true
# - setup_remote_docker:
# docker_layer_caching: true
- run:
name: Deploy latest version to viewer.ohif.org
command: |

View File

@ -2,18 +2,19 @@ import { LayoutButton } from '@ohif/ui';
import OHIF from '@ohif/core';
import { connect } from 'react-redux';
const { setLayout } = OHIF.redux.actions;
const { setLayout, setViewportActive } = OHIF.redux.actions;
const mapStateToProps = state => {
return {
currentLayout: state.viewports.layout,
activeViewportIndex: state.viewports.activeViewportIndex
};
};
const mapDispatchToProps = dispatch => {
return {
// TODO: Change if layout switched becomes more complex
onChange: (selectedCell, currentLayout) => {
onChange: (selectedCell, currentLayout, activeViewportIndex) => {
let viewports = [];
const rows = selectedCell.row + 1;
const columns = selectedCell.col + 1;
@ -36,6 +37,11 @@ const mapDispatchToProps = dispatch => {
viewports,
};
const maxActiveIndex = rows * columns - 1;
if (activeViewportIndex > maxActiveIndex) {
dispatch(setViewportActive(0));
}
dispatch(setLayout(layout));
},
};
@ -43,10 +49,10 @@ const mapDispatchToProps = dispatch => {
const mergeProps = (propsFromState, propsFromDispatch) => {
const onChangeFromDispatch = propsFromDispatch.onChange;
const { currentLayout } = propsFromState;
const { currentLayout, activeViewportIndex } = propsFromState;
return {
onChange: (selectedCell) => onChangeFromDispatch(selectedCell, currentLayout)
onChange: selectedCell => onChangeFromDispatch(selectedCell, currentLayout, activeViewportIndex)
};
}