Skip to content

Commit

Permalink
#233 fixed a bug where assignees would only be shown if they have con…
Browse files Browse the repository at this point in the history
…tributed to the project
  • Loading branch information
maerzman committed Jul 12, 2024
1 parent 26b3318 commit 52328e1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -72,8 +72,8 @@ class ChartComponent extends React.Component<Props, State> {
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)],
};
Expand Down Expand Up @@ -110,17 +110,21 @@ class ChartComponent extends React.Component<Props, State> {

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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ 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<Props> {
onClickCategory(category) {
this.props.setCategory(category);
}

onSetOnlyShowAuthors(value) {
this.props.setOnlyShowAuthors(value);
}

render() {
return (
<div className={styles.configContainer}>
Expand All @@ -32,6 +38,17 @@ class ConfigComponent extends React.Component<Props> {
/>
</div>
</div>
<div className={styles.field}>
<input
id="onlyShowAuthorsSwitch"
type="checkbox"
name="onlyShowAuthorsSwitch"
className={'switch is-rounded is-outlined is-info'}
value={this.props.mergeRequestOwnershipState.config.onlyShowAuthors}
onChange={(e) => this.onSetOnlyShowAuthors(e.target.checked)}
/>
<label htmlFor="onlyShowAuthorsSwitch">Only Show Authors</label>
</div>
</div>
);
}
Expand All @@ -44,6 +61,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = (dispatch /*, ownProps*/) => {
return {
setCategory: (category) => dispatch(setCategory(category)),
setOnlyShowAuthors: (value) => dispatch(onlyShowAuthors(value)),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
);
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 52328e1

Please sign in to comment.