diff --git a/packages/app/package.json b/packages/app/package.json index 3ac43d06f8..431728dfc3 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -25,7 +25,7 @@ "webpack-bundle-analyzer": "^3.0.3" }, "dependencies": { - "@dhis2/analytics": "^2.5.2", + "@dhis2/analytics": "^2.6.0", "@dhis2/d2-i18n": "^1.0.6", "@dhis2/d2-ui-core": "^6.2.1", "@dhis2/d2-ui-file-menu": "^6.2.1", diff --git a/packages/app/src/components/DimensionsPanel/DimensionsPanel.js b/packages/app/src/components/DimensionsPanel/DimensionsPanel.js index 8d95ca6642..7c9d104629 100644 --- a/packages/app/src/components/DimensionsPanel/DimensionsPanel.js +++ b/packages/app/src/components/DimensionsPanel/DimensionsPanel.js @@ -1,10 +1,9 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { - DIMENSION_ID_PERIOD, DimensionsPanel, DimensionMenu, - isYearOverYear, + getDisallowedDims, } from '@dhis2/analytics'; import DialogManager from './Dialogs/DialogManager'; @@ -21,6 +20,8 @@ import { acAddUiLayoutDimensions, acRemoveUiLayoutDimensions, } from '../../actions/ui'; +import { sGetUiType } from '../../reducers/ui'; +import { createSelector } from 'reselect'; export class Dimensions extends Component { state = { @@ -49,12 +50,8 @@ export class Dimensions extends Component { setDataTransfer(e, SOURCE_DIMENSIONS); }; - disabledDimension = dimension => { - return ( - dimension.id === DIMENSION_ID_PERIOD && - isYearOverYear(this.props.ui.type) - ); - }; + disabledDimension = dimension => + this.props.disallowedDimensions.includes(dimension.id); getUiAxisName = () => { const adaptedUi = getAdaptedUiByType(this.props.ui); @@ -98,6 +95,12 @@ export class Dimensions extends Component { ); } } + +const getDisallowedDimensions = createSelector( + [sGetUiType], + type => getDisallowedDims(type) +); + const mapStateToProps = state => { return { ui: fromReducers.fromUi.sGetUi(state), @@ -108,6 +111,7 @@ const mapStateToProps = state => { ), layout: fromReducers.fromUi.sGetUiLayout(state), itemsByDimension: fromReducers.fromUi.sGetUiItems(state), + disallowedDimensions: getDisallowedDimensions(state), }; }; diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 7165ab1af2..f626f5f096 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -5,7 +5,7 @@ "main": "./build/index.js", "license": "BSD-3-Clause", "dependencies": { - "@dhis2/analytics": "^2.5.2", + "@dhis2/analytics": "^2.6.0", "@material-ui/core": "^3.1.2", "lodash-es": "^4.17.11", "react": "^16.6.0", diff --git a/yarn.lock b/yarn.lock index f263d4b50a..cd17d3470b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -183,10 +183,10 @@ react-beautiful-dnd "^10.1.1" styled-jsx "^3.2.1" -"@dhis2/analytics@^2.5.2": - version "2.5.2" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.5.2.tgz#d7076653765947efee87ac5fac6d67c9815dae9d" - integrity sha512-BCySFEKXDUdGnw3Glnv+vZBdmA7a279jdAt69dDLAbea61phvkHrlSKmpRwuTtv3EB0UboaFxzE89/3n21XxGg== +"@dhis2/analytics@^2.6.0": + version "2.6.0" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.6.0.tgz#81f8a37acf76ac606f27e22986665723e54587d8" + integrity sha512-aYnUXxefEeJFZNJcHULA4jwFwbHKUkjrP8qSi2UHuho6M5TJGqb1oQOPth8NuALlYtShmJcP3tG0lcABeS2lUA== dependencies: "@dhis2/d2-i18n" "^1.0.4" "@dhis2/d2-ui-org-unit-dialog" "^6.3.0"