diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-12-14 16:16:44 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-12-16 11:17:32 +0100 |
commit | 5af187a6a0bda4f14de5d8ba5c6088c3a00d3e4e (patch) | |
tree | 24c4b4272bd73b225d73db23523f3441a486f2bc /server/sonar-web/src/main/js/apps/code/actions | |
parent | 5995432e51e72623804ffe926316b84d18913657 (diff) | |
download | sonarqube-5af187a6a0bda4f14de5d8ba5c6088c3a00d3e4e.tar.gz sonarqube-5af187a6a0bda4f14de5d8ba5c6088c3a00d3e4e.zip |
SONAR-7143 display list of components on the code page
Diffstat (limited to 'server/sonar-web/src/main/js/apps/code/actions')
-rw-r--r-- | server/sonar-web/src/main/js/apps/code/actions/index.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/code/actions/index.js b/server/sonar-web/src/main/js/apps/code/actions/index.js new file mode 100644 index 00000000000..9e9df67cfea --- /dev/null +++ b/server/sonar-web/src/main/js/apps/code/actions/index.js @@ -0,0 +1,70 @@ +import _ from 'underscore'; + +import { getChildren, getComponent } from '../../../api/components'; + + +const METRICS = [ + 'ncloc', + 'sqale_index', + 'violations', + // TODO handle other types of coverage + 'coverage', + 'duplicated_lines_density' +]; + + +export const INIT = 'INIT'; +export const BROWSE = 'BROWSE'; +export const RECEIVE_COMPONENTS = 'RECEIVE_COMPONENTS'; +export const SHOW_SOURCE = 'SHOW_SOURCE'; + + +export function requestComponents (baseComponent) { + return { + type: BROWSE, + baseComponent + }; +} + + +export function receiveComponents (baseComponent, components) { + return { + type: RECEIVE_COMPONENTS, + baseComponent, + components + }; +} + + +export function showSource (component) { + return { + type: SHOW_SOURCE, + component + }; +} + + +function fetchChildren (dispatch, baseComponent) { + dispatch(requestComponents(baseComponent)); + return getChildren(baseComponent.key, METRICS) + .then(components => _.sortBy(components, 'name')) + .then(components => dispatch(receiveComponents(baseComponent, components))); +} + + +export function initComponent (baseComponent) { + return dispatch => { + return getComponent(baseComponent.key, METRICS) + .then(component => fetchChildren(dispatch, component)); + }; +} + + +export function fetchComponents (baseComponent) { + return (dispatch, getState) => { + const { fetching } = getState(); + if (!fetching) { + return fetchChildren(dispatch, baseComponent); + } + }; +} |