-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
648 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { Component } from 'react' | ||
import LabelsIcon from 'react-icons/lib/fa/tags' | ||
import { TrapApiError, Widget, WidgetHeader, WidgetBody, WidgetLoader } from '@mozaik/ui' | ||
import { ResponsiveBubble } from 'nivo' | ||
import { labelsPropTypes, labelsDefaultProps } from './propTypes' | ||
import { countLabel } from './counts' | ||
|
||
export default class LabelsBubbles extends Component { | ||
static propTypes = labelsPropTypes | ||
|
||
static defaultProps = labelsDefaultProps | ||
|
||
static getApiRequest({ project }) { | ||
return { | ||
id: `gitlab.projectLabels.${project}`, | ||
params: { project }, | ||
} | ||
} | ||
|
||
render() { | ||
const { apiData, apiError, title, countBy, animate } = this.props | ||
|
||
let body = <WidgetLoader /> | ||
let subject = null | ||
let count = 0 | ||
if (apiData) { | ||
const { project, labels } = apiData | ||
|
||
count = labels.length | ||
|
||
const data = { | ||
name: 'labels', | ||
color: '#000', | ||
children: labels, | ||
} | ||
|
||
subject = ( | ||
<a href={project.web_url} target="_blank"> | ||
{project.name} | ||
</a> | ||
) | ||
|
||
body = ( | ||
<ResponsiveBubble | ||
root={data} | ||
labelSkipRadius={12} | ||
value={countBy} | ||
label={d => `${d.name} ${d[countBy]}`} | ||
labelTextColor="inherit:darker(1.6)" | ||
leavesOnly={true} | ||
colorBy={d => d.color} | ||
animate={animate} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<Widget> | ||
<WidgetHeader | ||
title={title || `Labels by ${countLabel(countBy)}`} | ||
subject={title ? null : subject} | ||
count={count} | ||
icon={LabelsIcon} | ||
/> | ||
<WidgetBody> | ||
<TrapApiError error={apiError}> | ||
{body} | ||
</TrapApiError> | ||
</WidgetBody> | ||
</Widget> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { Component } from 'react' | ||
import LabelsIcon from 'react-icons/lib/fa/tags' | ||
import { TrapApiError, Widget, WidgetHeader, WidgetBody, WidgetLoader } from '@mozaik/ui' | ||
import { ResponsivePie } from 'nivo' | ||
import { labelsPropTypes, labelsDefaultProps } from './propTypes' | ||
import { countLabel } from './counts' | ||
|
||
export default class LabelsPie extends Component { | ||
static propTypes = labelsPropTypes | ||
|
||
static defaultProps = labelsDefaultProps | ||
|
||
static getApiRequest({ project }) { | ||
return { | ||
id: `gitlab.projectLabels.${project}`, | ||
params: { project }, | ||
} | ||
} | ||
|
||
render() { | ||
const { apiData, apiError, title, countBy, animate } = this.props | ||
|
||
let body = <WidgetLoader /> | ||
let subject = null | ||
let count = 0 | ||
if (apiData) { | ||
const { project, labels } = apiData | ||
|
||
count = labels.length | ||
|
||
const data = labels.map(label => ({ | ||
...label, | ||
id: `${label.id}`, | ||
value: label[countBy], | ||
})) | ||
|
||
subject = ( | ||
<a href={project.web_url} target="_blank"> | ||
{project.name} | ||
</a> | ||
) | ||
|
||
body = ( | ||
<ResponsivePie | ||
data={data} | ||
colorBy={d => d.color} | ||
innerRadius={0.6} | ||
label={d => `${d.name} ${d.open_issues_count}`} | ||
animate={animate} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<Widget> | ||
<WidgetHeader | ||
title={title || `Labels by ${countLabel(countBy)}`} | ||
subject={title ? null : subject} | ||
count={count} | ||
icon={LabelsIcon} | ||
/> | ||
<WidgetBody> | ||
<TrapApiError error={apiError}> | ||
{body} | ||
</TrapApiError> | ||
</WidgetBody> | ||
</Widget> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { Component } from 'react' | ||
import LabelsIcon from 'react-icons/lib/fa/tags' | ||
import { TrapApiError, Widget, WidgetHeader, WidgetBody, WidgetLoader } from '@mozaik/ui' | ||
import { ResponsiveTreeMap } from 'nivo' | ||
import { labelsPropTypes, labelsDefaultProps } from './propTypes' | ||
import { countLabel } from './counts' | ||
|
||
export default class LabelsTreemap extends Component { | ||
static propTypes = labelsPropTypes | ||
|
||
static defaultProps = labelsDefaultProps | ||
|
||
static getApiRequest({ project }) { | ||
return { | ||
id: `gitlab.projectLabels.${project}`, | ||
params: { project }, | ||
} | ||
} | ||
|
||
render() { | ||
const { apiData, apiError, title, countBy, animate } = this.props | ||
|
||
let body = <WidgetLoader /> | ||
let subject = null | ||
let count = 0 | ||
if (apiData) { | ||
const { project, labels } = apiData | ||
|
||
count = labels.length | ||
|
||
const data = { | ||
name: 'labels', | ||
color: '#000', | ||
children: labels, | ||
} | ||
|
||
subject = ( | ||
<a href={project.web_url} target="_blank"> | ||
{project.name} | ||
</a> | ||
) | ||
|
||
body = ( | ||
<ResponsiveTreeMap | ||
root={data} | ||
tile="binary" | ||
labelSkipSize={12} | ||
identity="id" | ||
value={countBy} | ||
label={d => `${d.name} ${d[countBy]}`} | ||
labelTextColor="inherit:darker(1.6)" | ||
leavesOnly={true} | ||
outerPadding={10} | ||
innerPadding={2} | ||
colorBy={d => d.color} | ||
animate={animate} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<Widget> | ||
<WidgetHeader | ||
title={title || `Labels by ${countLabel(countBy)}`} | ||
subject={title ? null : subject} | ||
count={count} | ||
icon={LabelsIcon} | ||
/> | ||
<WidgetBody> | ||
<TrapApiError error={apiError}> | ||
{body} | ||
</TrapApiError> | ||
</WidgetBody> | ||
</Widget> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const countByLabels = { | ||
open_issues_count: 'open issues', | ||
closed_issues_count: 'closed issues', | ||
open_merge_requests_count: 'opened merge requests', | ||
} | ||
|
||
export const countTypes = Object.keys(countByLabels) | ||
|
||
export const countLabel = countType => countByLabels[countType] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as LabelsBubble } from './LabelsBubble' | ||
export { default as LabelsPie } from './LabelsPie' | ||
export { default as LabelsTreemap } from './LabelsTreemap' |
Oops, something went wrong.