diff --git a/binocular-frontend/src/visualizations/merge-request-ownership/chart/chart.tsx b/binocular-frontend/src/visualizations/merge-request-ownership/chart/chart.tsx index 75950ac4..497f4d9c 100644 --- a/binocular-frontend/src/visualizations/merge-request-ownership/chart/chart.tsx +++ b/binocular-frontend/src/visualizations/merge-request-ownership/chart/chart.tsx @@ -3,7 +3,7 @@ import React from 'react'; import _ from 'lodash'; import { connect } from 'react-redux'; import BubbleChart, { Bubble } from '../../../components/BubbleChart'; -import { Author, MergeRequest } from '../../../types/dbTypes'; +import { MergeRequest } from '../../../types/dbTypes'; import styles from '../styles.module.scss'; interface Props { @@ -72,8 +72,8 @@ class ChartComponent extends React.Component { categoryCount.forEach((count, assignee) => { const colors = ['red', 'green', 'blue', 'yellow']; const bubble: Bubble = { - x: 10 + Math.random(), - y: 10 + Math.random(), + x: 10, + y: 10, size: 50 + count, color: colors[Math.floor(Math.random() * (3 - 0 + 1) + 0)], }; @@ -110,17 +110,21 @@ class ChartComponent extends React.Component { for (const person of collection) { let authorHit = false; + let filter = false; + for (const author of Object.keys(props.allAuthors)) { - const authorName = author.split('<')[0].slice(0, -1); + const authorName = author.split('<')[0].slice(0, -1).replace(/\s+/g, ''); + if (person.login === authorName) { + authorHit = true; if (props.selectedAuthors.filter((a: string) => a === author).length > 0) { - authorHit = true; + filter = !props.mergeRequestOwnershipState.config.onlyShowAuthors; break; } } } - if (!authorHit) return; + if (authorHit && !filter) return; map.set(person.login, (map.get(person.login) || 0) + 1); } } diff --git a/binocular-frontend/src/visualizations/merge-request-ownership/config.tsx b/binocular-frontend/src/visualizations/merge-request-ownership/config.tsx index 5e7d7776..eae1d48d 100644 --- a/binocular-frontend/src/visualizations/merge-request-ownership/config.tsx +++ b/binocular-frontend/src/visualizations/merge-request-ownership/config.tsx @@ -4,11 +4,13 @@ import React from 'react'; import { connect } from 'react-redux'; import TabCombo from '../../components/TabCombo'; import styles from './styles.module.scss'; -import { setCategory } from './sagas'; +import { onlyShowAuthors, setCategory } from './sagas'; interface Props { mergeRequestOwnershipState: any; setCategory: (category: any) => void; + setOnlyShowAuthors: (value: boolean) => void; + onlyShowAuthors: boolean; } class ConfigComponent extends React.Component { @@ -16,6 +18,10 @@ class ConfigComponent extends React.Component { this.props.setCategory(category); } + onSetOnlyShowAuthors(value) { + this.props.setOnlyShowAuthors(value); + } + render() { return (
@@ -32,6 +38,17 @@ class ConfigComponent extends React.Component { />
+
+ this.onSetOnlyShowAuthors(e.target.checked)} + /> + +
); } @@ -44,6 +61,7 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = (dispatch /*, ownProps*/) => { return { setCategory: (category) => dispatch(setCategory(category)), + setOnlyShowAuthors: (value) => dispatch(onlyShowAuthors(value)), }; }; diff --git a/binocular-frontend/src/visualizations/merge-request-ownership/reducers/config.ts b/binocular-frontend/src/visualizations/merge-request-ownership/reducers/config.ts index b82aee5e..66bc26eb 100644 --- a/binocular-frontend/src/visualizations/merge-request-ownership/reducers/config.ts +++ b/binocular-frontend/src/visualizations/merge-request-ownership/reducers/config.ts @@ -6,7 +6,8 @@ export default handleActions( { SET_ACTIVE_VISUALIZATIONS: (state, action) => _.assign({}, state, { visualizations: action.payload }), SET_CATEGORY: (state, action) => _.assign({}, state, { category: action.payload }), + SET_ONLY_SHOW_AUTHORS: (state, action) => _.assign({}, state, { onlyShowAuthors: action.payload }), }, - { visualizations: [], category: 'assignees' }, + { visualizations: [], category: 'assignees', onlyShowAuthors: false }, ); diff --git a/binocular-frontend/src/visualizations/merge-request-ownership/sagas/index.ts b/binocular-frontend/src/visualizations/merge-request-ownership/sagas/index.ts index 3f89d5d8..96ad7567 100644 --- a/binocular-frontend/src/visualizations/merge-request-ownership/sagas/index.ts +++ b/binocular-frontend/src/visualizations/merge-request-ownership/sagas/index.ts @@ -9,6 +9,7 @@ export const requestMergeRequestOwnershipData = createAction('REQUEST_MERGE_REQU export const receiveMergeRequestOwnershipData = timestampedActionFactory('RECEIVE_MERGE_REQUEST_OWNERSHIP_DATA'); export const receiveMergeRequestOwnershipDataError = createAction('RECEIVE_MERGE_REQUEST_OWNERSHIP_DATA_ERROR'); export const setCategory = createAction('SET_CATEGORY'); +export const onlyShowAuthors = createAction('SET_ONLY_SHOW_AUTHORS'); export default function* () { yield* fetchMergeRequestOwnershipData();