From 2a743554b65960be6f36bd2e60d0624e11375e42 Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Wed, 9 Oct 2019 16:37:26 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20set=20current=20viewport?= =?UTF-8?q?=20as=20active=20when=20switching=20layouts=20(#1018)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .circleci/config.yml | 8 ++++---- .../connectedComponents/ConnectedLayoutButton.js | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b1892def8..17e0d02bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: | diff --git a/platform/viewer/src/connectedComponents/ConnectedLayoutButton.js b/platform/viewer/src/connectedComponents/ConnectedLayoutButton.js index db317bec6..2f2588e4f 100644 --- a/platform/viewer/src/connectedComponents/ConnectedLayoutButton.js +++ b/platform/viewer/src/connectedComponents/ConnectedLayoutButton.js @@ -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) }; }