diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-09-23 17:42:18 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-09-30 17:23:37 +0200 |
commit | 40bb40f37b47e8d5825ef349ec68c70e6b1d06c8 (patch) | |
tree | b572767548b0f5d44ad0cd026cee8ae8d6729ceb /server/sonar-web/src/main/js/app/store/measures | |
parent | e9756989048439cb1c4b8eabf5fafb868b93f67e (diff) | |
download | sonarqube-40bb40f37b47e8d5825ef349ec68c70e6b1d06c8.tar.gz sonarqube-40bb40f37b47e8d5825ef349ec68c70e6b1d06c8.zip |
SONAR-8170 SONAR-8171 Reorganize My Account space
Diffstat (limited to 'server/sonar-web/src/main/js/app/store/measures')
-rw-r--r-- | server/sonar-web/src/main/js/app/store/measures/actions.js | 27 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/app/store/measures/reducer.js | 44 |
2 files changed, 71 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/app/store/measures/actions.js b/server/sonar-web/src/main/js/app/store/measures/actions.js new file mode 100644 index 00000000000..7445f7fae44 --- /dev/null +++ b/server/sonar-web/src/main/js/app/store/measures/actions.js @@ -0,0 +1,27 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +export const RECEIVE_COMPONENT_MEASURE = 'RECEIVE_COMPONENT_MEASURE'; + +export const receiveComponentMeasure = (componentKey, metricKey, value) => ({ + type: RECEIVE_COMPONENT_MEASURE, + componentKey, + metricKey, + value +}); diff --git a/server/sonar-web/src/main/js/app/store/measures/reducer.js b/server/sonar-web/src/main/js/app/store/measures/reducer.js new file mode 100644 index 00000000000..5197ebf8dd5 --- /dev/null +++ b/server/sonar-web/src/main/js/app/store/measures/reducer.js @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { RECEIVE_COMPONENT_MEASURE } from './actions'; + +const byMetricKey = (state = {}, action = {}) => { + if (action.type === RECEIVE_COMPONENT_MEASURE) { + return { ...state, [action.metricKey]: action.value }; + } + + return state; +}; + +const reducer = (state = {}, action = {}) => { + if (action.type === RECEIVE_COMPONENT_MEASURE) { + const component = state[action.componentKey]; + return { ...state, [action.componentKey]: byMetricKey(component, action) }; + } + + return state; +}; + +export default reducer; + +export const getComponentMeasure = (state, componentKey, metricKey) => { + const component = state[componentKey]; + return component && component[metricKey]; +}; |