-
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
20 changed files
with
1,215 additions
and
364 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
import React, { Component } from 'react' | ||
import { ResponsiveBubble } from 'nivo' | ||
import LabelsChart from './LabelsChart' | ||
|
||
const margin = { | ||
top: 10, | ||
right: 10, | ||
bottom: 10, | ||
left: 10, | ||
} | ||
|
||
export default class LabelsBubble extends Component { | ||
static getApiRequest = LabelsChart.getApiRequest | ||
|
||
render() { | ||
return ( | ||
<LabelsChart {...this.props}> | ||
{({ labels, countBy, animate }) => { | ||
const data = { | ||
name: 'labels', | ||
color: '#000', | ||
children: labels, | ||
} | ||
|
||
return ( | ||
<ResponsiveBubble | ||
root={data} | ||
margin={margin} | ||
labelSkipRadius={12} | ||
value={countBy} | ||
label={d => `${d.name} ${d[countBy]}`} | ||
labelTextColor="inherit:darker(1.6)" | ||
leavesOnly={true} | ||
colorBy={d => d.color} | ||
animate={animate} | ||
/> | ||
) | ||
}} | ||
</LabelsChart> | ||
) | ||
} | ||
} |
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,87 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import LabelsIcon from 'react-icons/lib/fa/tags' | ||
import { TrapApiError, Widget, WidgetHeader, WidgetBody, WidgetLoader } from '@mozaik/ui' | ||
import { countTypes, countLabel } from './counts' | ||
|
||
export default class LabelsChart extends Component { | ||
static propTypes = { | ||
project: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
countBy: PropTypes.oneOf(countTypes).isRequired, | ||
apiData: PropTypes.shape({ | ||
project: PropTypes.shape({ | ||
name: PropTypes.string.isRequired, | ||
web_url: PropTypes.string.isRequired, | ||
}).isRequired, | ||
labels: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
id: PropTypes.number.isRequired, | ||
name: PropTypes.string.isRequired, | ||
color: PropTypes.string.isRequired, | ||
open_issues_count: PropTypes.number.isRequired, | ||
closed_issues_count: PropTypes.number.isRequired, | ||
open_merge_requests_count: PropTypes.number.isRequired, | ||
}) | ||
).isRequired, | ||
}), | ||
apiError: PropTypes.object, | ||
title: PropTypes.string, | ||
animate: PropTypes.bool.isRequired, | ||
children: PropTypes.func.isRequired, | ||
theme: PropTypes.object.isRequired, | ||
} | ||
|
||
static defaultProps = { | ||
countBy: 'open_issues_count', | ||
animate: false, | ||
} | ||
|
||
static getApiRequest({ project }) { | ||
return { | ||
id: `gitlab.projectLabels.${project}`, | ||
params: { project }, | ||
} | ||
} | ||
|
||
render() { | ||
const { apiData, apiError, title, countBy, animate, children, theme } = this.props | ||
|
||
let body = <WidgetLoader /> | ||
let subject = null | ||
let count = 0 | ||
if (apiData) { | ||
const { project, labels } = apiData | ||
|
||
count = labels.length | ||
|
||
subject = ( | ||
<a href={project.web_url} target="_blank"> | ||
{project.name} | ||
</a> | ||
) | ||
|
||
body = children({ | ||
labels, | ||
countBy, | ||
animate, | ||
theme: theme.charts, | ||
}) | ||
} | ||
|
||
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,48 @@ | ||
import React, { Component } from 'react' | ||
import { ResponsivePie } from 'nivo' | ||
import LabelsChart from './LabelsChart' | ||
|
||
const margin = { | ||
top: 30, | ||
right: 60, | ||
bottom: 30, | ||
left: 60, | ||
} | ||
|
||
const skipAngle = 5 | ||
|
||
export default class LabelsPie extends Component { | ||
static getApiRequest = LabelsChart.getApiRequest | ||
|
||
render() { | ||
return ( | ||
<LabelsChart {...this.props}> | ||
{({ labels, countBy, animate, theme }) => { | ||
const data = labels.map(label => ({ | ||
...label, | ||
id: `${label.id}`, | ||
label: label.name, | ||
value: label[countBy], | ||
})) | ||
|
||
return ( | ||
<ResponsivePie | ||
data={data} | ||
margin={margin} | ||
colorBy={d => d.color} | ||
innerRadius={0.6} | ||
padAngle={1} | ||
radialLabel="name" | ||
radialLabelsSkipAngle={skipAngle} | ||
slicesLabel={countBy} | ||
slicesLabelsSkipAngle={skipAngle} | ||
slicesLabelsTextColor="inherit:darker(1.6)" | ||
animate={animate} | ||
theme={theme} | ||
/> | ||
) | ||
}} | ||
</LabelsChart> | ||
) | ||
} | ||
} |
Oops, something went wrong.