From 50ca2bde971e1e67b73ece96369052dd1a35ac68 Mon Sep 17 00:00:00 2001 From: Danny Brown Date: Wed, 30 Oct 2019 11:15:51 -0400 Subject: [PATCH] fix: get adapter store picker to show (#1134) --- .../viewer/src/studylist/StudyListRoute.js | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/platform/viewer/src/studylist/StudyListRoute.js b/platform/viewer/src/studylist/StudyListRoute.js index 29e43d30f..8e2c4eb2d 100644 --- a/platform/viewer/src/studylist/StudyListRoute.js +++ b/platform/viewer/src/studylist/StudyListRoute.js @@ -1,9 +1,9 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useContext } from 'react'; import PropTypes from 'prop-types'; import Dropzone from 'react-dropzone'; import OHIF from '@ohif/core'; import { withRouter } from 'react-router-dom'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import { StudyList, PageToolbar, @@ -26,7 +26,8 @@ import AppContext from '../context/AppContext'; const { urlUtil: UrlUtil } = OHIF.utils; function StudyListRoute(props) { - const { history, server, t, user, studyListFunctionsEnabled } = props; + const { history, server, user, studyListFunctionsEnabled } = props; + const [t] = useTranslation('Common'); // ~~ STATE const [sort, setSort] = useState({ fieldName: 'patientName', @@ -55,6 +56,7 @@ function StudyListRoute(props) { const [activeModalId, setActiveModalId] = useState(null); const [rowsPerPage, setRowsPerPage] = useState(25); const [pageNumber, setPageNumber] = useState(0); + const appContext = useContext(AppContext); // ~~ RESPONSIVE const displaySize = useMedia( ['(min-width: 1750px)', '(min-width: 1000px)', '(min-width: 768px)'], @@ -66,10 +68,10 @@ function StudyListRoute(props) { const debouncedFilters = useDebounce(filterValues, 250); // Google Cloud Adapter for DICOM Store Picking - const { appConfig = {} } = AppContext; + const { appConfig = {} } = appContext; const isGoogleCHAIntegrationEnabled = !server && appConfig.enableGoogleCloudAdapter; - if (isGoogleCHAIntegrationEnabled) { + if (isGoogleCHAIntegrationEnabled && activeModalId !== 'DicomStorePicker') { setActiveModalId('DicomStorePicker'); } @@ -97,8 +99,17 @@ function StudyListRoute(props) { } }; - fetchStudies(); - }, [debouncedFilters, debouncedSort, rowsPerPage, pageNumber, displaySize]); + if (server) { + fetchStudies(); + } + }, [ + debouncedFilters, + debouncedSort, + rowsPerPage, + pageNumber, + displaySize, + server, + ]); // TODO: Update Server // if (this.props.server !== prevProps.server) { @@ -181,6 +192,13 @@ function StudyListRoute(props) { return ( <> + {studyListFunctionsEnabled ? ( + setActiveModalId(null)} + /> + ) : null} + {healthCareApiWindows} {whiteLabelling => ( @@ -203,6 +221,7 @@ function StudyListRoute(props) {
+ {studyListFunctionsEnabled && healthCareApiButtons} {studyListFunctionsEnabled && ( setActiveModalId('DicomFilesUploader')} @@ -232,17 +251,8 @@ function StudyListRoute(props) { filterValues={filterValues} onFilterChange={handleFilterChange} studyListDateFilterNumDays={appConfig.studyListDateFilterNumDays} - > - {studyListFunctionsEnabled ? ( - setActiveModalId(null)} - /> - ) : null} - {healthCareApiButtons} - {healthCareApiWindows} - - }{/* PAGINATION FOOTER */} + /> + {/* PAGINATION FOOTER */} setPageNumber(pageNumber + 1)} @@ -407,7 +417,7 @@ function _sortStudies(studies, field, order) { }); // Sort by field - sortedStudies.sort(function (a, b) { + sortedStudies.sort(function(a, b) { let fieldA = a[field]; let fieldB = b[field]; if (field === 'studyDate') { @@ -549,4 +559,4 @@ function _getQueryFiltersForValue(filters, fields, value) { return queryFilters; } -export default withRouter(withTranslation('Common')(StudyListRoute)); +export default withRouter(StudyListRoute);