diff --git a/package.json b/package.json index 8b873014d..778a7fe54 100644 --- a/package.json +++ b/package.json @@ -5,17 +5,17 @@ "private": true, "license": "BSD-3-Clause", "dependencies": { - "@dhis2/analytics": "^10.0.2", + "@dhis2/analytics": "^10.0.3", "@dhis2/app-runtime": "^2.2.2", "@dhis2/app-runtime-adapter-d2": "^1.0.1", "@dhis2/d2-i18n": "^1.0.6", "@dhis2/d2-ui-core": "^7.0.3", - "@dhis2/d2-ui-interpretations": "^7.0.4", + "@dhis2/d2-ui-interpretations": "^7.0.7", "@dhis2/d2-ui-mentions-wrapper": "^7.0.3", "@dhis2/d2-ui-rich-text": "^7.0.4", "@dhis2/d2-ui-sharing-dialog": "^7.0.5", "@dhis2/d2-ui-translation-dialog": "^7.0.4", - "@dhis2/data-visualizer-plugin": "^35.12.9", + "@dhis2/data-visualizer-plugin": "^35.12.10", "@dhis2/ui": "^5.5.4", "@material-ui/core": "^3.9.2", "@material-ui/icons": "^4.9.1", diff --git a/src/actions/windowHeight.js b/src/actions/windowHeight.js new file mode 100644 index 000000000..56f19a256 --- /dev/null +++ b/src/actions/windowHeight.js @@ -0,0 +1,6 @@ +import { SET_WINDOW_HEIGHT } from '../reducers/windowHeight' + +export const acSetWindowHeight = value => ({ + type: SET_WINDOW_HEIGHT, + value, +}) diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index 88d155df7..b78c1b44a 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types' import isEmpty from 'lodash/isEmpty' import i18n from '@dhis2/d2-i18n' import { Layer, CenteredContent, CircularLoader } from '@dhis2/ui' +import debounce from 'lodash/debounce' import DashboardsBar from '../ControlBar/DashboardsBar' import DashboardVerticalOffset from './DashboardVerticalOffset' @@ -15,6 +16,7 @@ import PrintDashboard from './PrintDashboard' import PrintLayoutDashboard from './PrintLayoutDashboard' import { tSelectDashboard } from '../../actions/dashboards' +import { acSetWindowHeight } from '../../actions/windowHeight' import { sDashboardsIsFetching, sGetAllDashboards, @@ -61,6 +63,10 @@ export class Dashboard extends Component { } componentDidMount() { + window.onresize = debounce( + () => this.props.setWindowHeight(window.innerHeight), + 300 + ) this.setDashboard() } @@ -122,6 +128,7 @@ Dashboard.propTypes = { match: PropTypes.object, mode: PropTypes.string, selectDashboard: PropTypes.func, + setWindowHeight: PropTypes.func, } const mapStateToProps = state => { @@ -135,4 +142,5 @@ const mapStateToProps = state => { export default connect(mapStateToProps, { selectDashboard: tSelectDashboard, + setWindowHeight: acSetWindowHeight, })(Dashboard) diff --git a/src/components/Dashboard/EditDashboard.js b/src/components/Dashboard/EditDashboard.js index 39972bc83..3c249bafe 100644 --- a/src/components/Dashboard/EditDashboard.js +++ b/src/components/Dashboard/EditDashboard.js @@ -9,6 +9,7 @@ import EditBar from '../ControlBar/EditBar' import LayoutPrintPreview from './PrintLayoutDashboard' import NoContentMessage from '../../widgets/NoContentMessage' import { acSetEditDashboard } from '../../actions/editDashboard' +import { sGetWindowHeight } from '../../reducers/windowHeight' import { sGetSelectedId } from '../../reducers/selected' import { sGetDashboardById, @@ -48,7 +49,7 @@ export class EditDashboard extends Component { } const height = - window.innerHeight - HEADERBAR_HEIGHT - getControlBarHeight(1) + this.props.windowHeight - HEADERBAR_HEIGHT - getControlBarHeight(1) return (
@@ -78,6 +79,7 @@ EditDashboard.propTypes = { items: PropTypes.array, setEditDashboard: PropTypes.func, updateAccess: PropTypes.bool, + windowHeight: PropTypes.number, } const mapStateToProps = state => { @@ -92,6 +94,7 @@ const mapStateToProps = state => { updateAccess, items: sGetDashboardItems(state), isPrintPreviewView: sGetIsPrintPreviewView(state), + windowHeight: sGetWindowHeight(state), } } diff --git a/src/components/Dashboard/NewDashboard.js b/src/components/Dashboard/NewDashboard.js index 4d6547d40..57a3d2e1f 100644 --- a/src/components/Dashboard/NewDashboard.js +++ b/src/components/Dashboard/NewDashboard.js @@ -9,6 +9,7 @@ import LayoutPrintPreview from './PrintLayoutDashboard' import { acSetEditNewDashboard } from '../../actions/editDashboard' import { sGetIsPrintPreviewView } from '../../reducers/editDashboard' +import { sGetWindowHeight } from '../../reducers/windowHeight' import { getControlBarHeight, @@ -22,7 +23,7 @@ class NewDashboard extends Component { render() { const height = - window.innerHeight - HEADERBAR_HEIGHT - getControlBarHeight(1) + this.props.windowHeight - HEADERBAR_HEIGHT - getControlBarHeight(1) return ( <> @@ -43,10 +44,12 @@ class NewDashboard extends Component { NewDashboard.propTypes = { isPrintPreviewView: PropTypes.bool, setNewDashboard: PropTypes.func, + windowHeight: PropTypes.number, } const mapStateToProps = state => ({ isPrintPreviewView: sGetIsPrintPreviewView(state), + windowHeight: sGetWindowHeight(state), }) export default connect(mapStateToProps, { diff --git a/src/components/Dashboard/PrintDashboard.js b/src/components/Dashboard/PrintDashboard.js index f33140198..bf981f954 100644 --- a/src/components/Dashboard/PrintDashboard.js +++ b/src/components/Dashboard/PrintDashboard.js @@ -12,6 +12,7 @@ import { acRemovePrintDashboardItem, } from '../../actions/printDashboard' import { sGetSelectedId } from '../../reducers/selected' +import { sGetWindowHeight } from '../../reducers/windowHeight' import { sGetDashboardById, sGetDashboardItems, @@ -77,7 +78,7 @@ export class PrintDashboard extends Component { } render() { - const height = window.innerHeight - PRINT_ACTIONS_BAR_HEIGHT + const height = this.props.windowHeight - PRINT_ACTIONS_BAR_HEIGHT return ( <> @@ -102,6 +103,7 @@ PrintDashboard.propTypes = { items: PropTypes.array, removeDashboardItem: PropTypes.func, setPrintDashboard: PropTypes.func, + windowHeight: PropTypes.number, } const mapStateToProps = state => { @@ -112,6 +114,7 @@ const mapStateToProps = state => { dashboard, id, items: sGetDashboardItems(state), + windowHeight: sGetWindowHeight(state), } } diff --git a/src/components/Dashboard/PrintLayoutDashboard.js b/src/components/Dashboard/PrintLayoutDashboard.js index 8b5cc2720..d5cfba726 100644 --- a/src/components/Dashboard/PrintLayoutDashboard.js +++ b/src/components/Dashboard/PrintLayoutDashboard.js @@ -13,6 +13,7 @@ import { acUpdatePrintDashboardItem, } from '../../actions/printDashboard' import { sGetSelectedId } from '../../reducers/selected' +import { sGetWindowHeight } from '../../reducers/windowHeight' import { sGetEditDashboardRoot, sGetEditDashboardItems, @@ -124,10 +125,12 @@ export class PrintLayoutDashboard extends Component { ? { paddingTop: spacers.dp24, height: - window.innerHeight - EDIT_BAR_HEIGHT - HEADERBAR_HEIGHT, + this.props.windowHeight - + EDIT_BAR_HEIGHT - + HEADERBAR_HEIGHT, } : { - height: window.innerHeight - PRINT_ACTIONS_BAR_HEIGHT, + height: this.props.windowHeight - PRINT_ACTIONS_BAR_HEIGHT, } } @@ -161,6 +164,7 @@ PrintLayoutDashboard.propTypes = { items: PropTypes.array, setPrintDashboard: PropTypes.func, updateDashboardItem: PropTypes.func, + windowHeight: PropTypes.number, } const mapStateToProps = (state, ownProps) => { @@ -173,6 +177,7 @@ const mapStateToProps = (state, ownProps) => { dashboard, id, items: sGetEditDashboardItems(state), + windowHeight: sGetWindowHeight(state), } } @@ -182,6 +187,7 @@ const mapStateToProps = (state, ownProps) => { dashboard, id, items: sGetDashboardItems(state), + windowHeight: sGetWindowHeight(state), } } diff --git a/src/components/Dashboard/ViewDashboard.js b/src/components/Dashboard/ViewDashboard.js index 3b0773f8f..23d4bccc1 100644 --- a/src/components/Dashboard/ViewDashboard.js +++ b/src/components/Dashboard/ViewDashboard.js @@ -10,6 +10,7 @@ import DashboardVerticalOffset from './DashboardVerticalOffset' import { sGetIsEditing } from '../../reducers/editDashboard' import { sGetIsPrinting } from '../../reducers/printDashboard' import { sGetSelectedId } from '../../reducers/selected' +import { sGetWindowHeight } from '../../reducers/windowHeight' import { sGetControlBarUserRows } from '../../reducers/controlBar' import { acClearEditDashboard } from '../../actions/editDashboard' import { acClearPrintDashboard } from '../../actions/printDashboard' @@ -32,7 +33,7 @@ export const ViewDashboard = props => { }, [props.selectedId]) const height = - window.innerHeight - + props.windowHeight - HEADERBAR_HEIGHT - getControlBarHeight(props.controlBarRows) @@ -56,6 +57,7 @@ ViewDashboard.propTypes = { dashboardIsEditing: PropTypes.bool, dashboardIsPrinting: PropTypes.bool, selectedId: PropTypes.string, + windowHeight: PropTypes.number, } const mapStateToProps = state => { @@ -64,6 +66,7 @@ const mapStateToProps = state => { dashboardIsPrinting: sGetIsPrinting(state), controlBarRows: sGetControlBarUserRows(state), selectedId: sGetSelectedId(state), + windowHeight: sGetWindowHeight(state), } } diff --git a/src/components/Dashboard/__tests__/EditDashboard.spec.js b/src/components/Dashboard/__tests__/EditDashboard.spec.js index fe16d0c63..1c0edd105 100644 --- a/src/components/Dashboard/__tests__/EditDashboard.spec.js +++ b/src/components/Dashboard/__tests__/EditDashboard.spec.js @@ -22,6 +22,7 @@ describe('EditDashboard', () => { items: undefined, dashboardsLoaded: undefined, isPrintPreviewView: undefined, + windowHeight: 600, } }) diff --git a/src/components/Dashboard/__tests__/ViewDashboard.spec.js b/src/components/Dashboard/__tests__/ViewDashboard.spec.js index 313b5066b..5fb9c3334 100644 --- a/src/components/Dashboard/__tests__/ViewDashboard.spec.js +++ b/src/components/Dashboard/__tests__/ViewDashboard.spec.js @@ -24,6 +24,7 @@ describe('ViewDashboard', () => { dashboardIsEditing: false, dashboardIsPrinting: false, controlBarRows: 2, + windowHeight: 600, } }) diff --git a/src/components/Dashboard/__tests__/__snapshots__/EditDashboard.spec.js.snap b/src/components/Dashboard/__tests__/__snapshots__/EditDashboard.spec.js.snap index e58517503..55652f848 100644 --- a/src/components/Dashboard/__tests__/__snapshots__/EditDashboard.spec.js.snap +++ b/src/components/Dashboard/__tests__/__snapshots__/EditDashboard.spec.js.snap @@ -7,7 +7,7 @@ exports[`EditDashboard renders message when enough access 1`] = ` className="dashboard-wrapper" style={ Object { - "height": 656, + "height": 488, } } > diff --git a/src/components/Dashboard/__tests__/__snapshots__/ViewDashboard.spec.js.snap b/src/components/Dashboard/__tests__/__snapshots__/ViewDashboard.spec.js.snap index 60712f37e..9609b4b87 100644 --- a/src/components/Dashboard/__tests__/__snapshots__/ViewDashboard.spec.js.snap +++ b/src/components/Dashboard/__tests__/__snapshots__/ViewDashboard.spec.js.snap @@ -8,7 +8,7 @@ exports[`ViewDashboard renders correctly default 1`] = ` className="dashboard-wrapper" style={ Object { - "height": 616, + "height": 448, } } > diff --git a/src/reducers/index.js b/src/reducers/index.js index e345db74c..bc29ae33d 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -21,6 +21,7 @@ import style from './style' import dimensions from './dimensions' import settings from './settings' import activeModalDimension from './activeModalDimension' +import windowHeight from './windowHeight' const USER = 'system' @@ -42,6 +43,7 @@ export default combineReducers({ dimensions, settings, activeModalDimension, + windowHeight, }) // Map constants to data diff --git a/src/reducers/windowHeight.js b/src/reducers/windowHeight.js new file mode 100644 index 000000000..81934b7e4 --- /dev/null +++ b/src/reducers/windowHeight.js @@ -0,0 +1,15 @@ +export const SET_WINDOW_HEIGHT = 'SET_WINDOW_HEIGHT' + +export const DEFAULT_STATE_WINDOW_HEIGHT = window.innerHeight + +export default (state = DEFAULT_STATE_WINDOW_HEIGHT, action) => { + switch (action.type) { + case SET_WINDOW_HEIGHT: { + return action.value + } + default: + return state + } +} + +export const sGetWindowHeight = state => state.windowHeight diff --git a/yarn.lock b/yarn.lock index 74d937721..d48997906 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1321,10 +1321,10 @@ resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-10.1.0.tgz#f0950bba18819512d42f7197e56c518aa491cf18" integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg== -"@dhis2/analytics@^10.0.2": - version "10.0.2" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-10.0.2.tgz#fd3f74da75676a019fec2322c7fdd1280f1ce7bc" - integrity sha512-+LVHc/1zwDJcJJlOv3NXb7sO9oVwysx2XoSuxJVjfoo97j5yKAKix3fkK75vt26lPdXMGFFAbHJshZiBguq8+g== +"@dhis2/analytics@^10.0.3": + version "10.0.3" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-10.0.3.tgz#9636bec30824b2a589964364a3b99296c104d7f2" + integrity sha512-h81hEvoHJDQshR024gSi/aBa9tpMQ8pwSPpNEDAEzw9QwR3eoNqMkTF8xDc3gO3HcJnfYMrYfdoiLYrQyhE+ZA== dependencies: "@dhis2/d2-ui-org-unit-dialog" "^7.0.5" "@dhis2/ui" "^5.5.3" @@ -1492,14 +1492,25 @@ material-ui "^0.20.0" rxjs "^5.5.7" -"@dhis2/d2-ui-interpretations@^7.0.4": - version "7.0.5" - resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-interpretations/-/d2-ui-interpretations-7.0.5.tgz#77d2e6a75a738c346307b0551e2f57a598f120b3" - integrity sha512-LeayAD2Df+bjm43+DTfOmBA4KoM2jQAMtRe5QU20cn23WCJasuPhcdo4kQKxDsMN7Na1KGUyH/qtsa2SlIXMYw== +"@dhis2/d2-ui-core@7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-core/-/d2-ui-core-7.0.7.tgz#2d8b504916b3283e54d59c0ef17a76a94468a9de" + integrity sha512-C4UmZrJar+xwhNjCj9SbwoU0tBCxOBphcvn2PjK4z8+tJrG9qTqpJNOw33VZgI6jOxlW1CCh7SPiP5phDUufJw== + dependencies: + babel-runtime "^6.26.0" + d2 "~31.7" + lodash "^4.17.10" + material-ui "^0.20.0" + rxjs "^5.5.7" + +"@dhis2/d2-ui-interpretations@^7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-interpretations/-/d2-ui-interpretations-7.0.7.tgz#ac5ea14b5488a249f5ec3af9a9e1d2e2cfaa1bfb" + integrity sha512-pDgEM0Q/IwG3LrCTi+JBVWbzb2iMJ1SThCHtkG/VunStRpLj3AB24Ae6LZxbQgGQeDeU3BGZwMMp9BjTi1/10Q== dependencies: - "@dhis2/d2-ui-mentions-wrapper" "7.0.5" - "@dhis2/d2-ui-rich-text" "7.0.5" - "@dhis2/d2-ui-sharing-dialog" "7.0.5" + "@dhis2/d2-ui-mentions-wrapper" "7.0.7" + "@dhis2/d2-ui-rich-text" "7.0.7" + "@dhis2/d2-ui-sharing-dialog" "7.0.7" "@material-ui/core" "^3.3.1" "@material-ui/icons" "^3.0.1" babel-runtime "^6.26.0" @@ -1509,7 +1520,16 @@ prop-types "^15.5.10" react-portal "^4.1.5" -"@dhis2/d2-ui-mentions-wrapper@7.0.5", "@dhis2/d2-ui-mentions-wrapper@^7.0.3": +"@dhis2/d2-ui-mentions-wrapper@7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-mentions-wrapper/-/d2-ui-mentions-wrapper-7.0.7.tgz#34d5ff75e71979b8ceca4531a5f12cc69b9f14d9" + integrity sha512-bgqJKhliGw7kxFJ+l33ro9mDeX/7SGwb4BtdnHvf6Dwm2IOtQkU0FCUDVWc/GtrN8lilQ4oJGE0diTDkuSgzoQ== + dependencies: + "@material-ui/core" "^3.3.1" + lodash "^4.17.10" + prop-types "^15.6.2" + +"@dhis2/d2-ui-mentions-wrapper@^7.0.3": version "7.0.5" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-mentions-wrapper/-/d2-ui-mentions-wrapper-7.0.5.tgz#a8ab1d85af4e862965a016b2009bfa48659b7699" integrity sha512-6+Px03gJHTboVz5KTBTBXHVhrnWDIqkC4ym3o332Rs0Gi4uEb4iHmJQrGtVrSWByxBllX73x080hvQXNxTz9SQ== @@ -1538,7 +1558,16 @@ babel-runtime "^6.26.0" prop-types "^15.5.10" -"@dhis2/d2-ui-rich-text@7.0.5", "@dhis2/d2-ui-rich-text@^7.0.4": +"@dhis2/d2-ui-rich-text@7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-rich-text/-/d2-ui-rich-text-7.0.7.tgz#b108340ee342b7d75e1e9d3b484a7cc98da2dbdd" + integrity sha512-qduwYqTRCFkZ5VpWSDEfpdQhN17eL/PDXgPVLvo4f0cMMkN9bR7e1q0BeemTvpCqTfHxQ+pjiHyaTwqBpzfzTg== + dependencies: + babel-runtime "^6.26.0" + markdown-it "^8.4.2" + prop-types "^15.6.2" + +"@dhis2/d2-ui-rich-text@^7.0.4": version "7.0.5" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-rich-text/-/d2-ui-rich-text-7.0.5.tgz#79ab4a915a02fa58945d72e20abdd0d072ef1d1e" integrity sha512-3vNvHvzZy5Umtogb/IqpcjtCKpJGP+4g52fTMNdCXFU286Sk2XX/99bWxrSyn0gGxK00/KNJx5uZVECtTkO++A== @@ -1547,7 +1576,21 @@ markdown-it "^8.4.2" prop-types "^15.6.2" -"@dhis2/d2-ui-sharing-dialog@7.0.5", "@dhis2/d2-ui-sharing-dialog@^7.0.5": +"@dhis2/d2-ui-sharing-dialog@7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-sharing-dialog/-/d2-ui-sharing-dialog-7.0.7.tgz#efadb2256116cf171487e565c43410e51efb8af9" + integrity sha512-iPsSIMhRVqTMXCC8N1ypGZRXzki4i1/Lsn5jVyOfM8IwNUG3X5FKbb56MjM8uU4G/q/p0n7/6M3CITmtGUzezg== + dependencies: + "@dhis2/d2-ui-core" "7.0.7" + "@material-ui/core" "^3.3.1" + "@material-ui/icons" "^3.0.1" + babel-runtime "^6.26.0" + downshift "^2.2.2" + prop-types "^15.5.10" + recompose "^0.26.0" + rxjs "^5.5.7" + +"@dhis2/d2-ui-sharing-dialog@^7.0.5": version "7.0.5" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-sharing-dialog/-/d2-ui-sharing-dialog-7.0.5.tgz#b73b587f004d7e81c2d2eb6fddade2f1e49b9b3e" integrity sha512-lxWvDs7Qj2/322myRQuxu32YeblmY5/SDoKKy1C/R3ZCLqPn8l7tE2XsCKXs89+gKzr8Qh4VeACnSKjv50DoFQ== @@ -1575,13 +1618,13 @@ react-select "^2.0.0" rxjs "^5.5.7" -"@dhis2/data-visualizer-plugin@^35.12.9": - version "35.12.9" - resolved "https://registry.yarnpkg.com/@dhis2/data-visualizer-plugin/-/data-visualizer-plugin-35.12.9.tgz#01e4695736859bad395f32181209d7f5463d80b9" - integrity sha512-IFuIJ7EvcmP7ts+I+vBmV/7OSsU9aI7mSbv4E8nkjAOutzAyoB8d5+vQ5qZo2jPoGH+ixWmYZU8QwJLljb9VGA== +"@dhis2/data-visualizer-plugin@^35.12.10": + version "35.12.10" + resolved "https://registry.yarnpkg.com/@dhis2/data-visualizer-plugin/-/data-visualizer-plugin-35.12.10.tgz#5d28465c0e5b93556fec614be29ede0aa9d7adc1" + integrity sha512-2rDVXX9gyTMrj+zGVf9wBL0f0m1NYOiuNzIrVgVX2M/YJbkUnuiZlCv54Z0jO93PRmMJ+Q58KbJqxvpoYsjSgg== dependencies: - "@dhis2/analytics" "^10.0.2" - "@dhis2/ui" "^5.5.3" + "@dhis2/analytics" "^10.0.3" + "@dhis2/ui" "^5.5.4" lodash-es "^4.17.11" "@dhis2/prop-types@^1.6.4":