-
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.
feat(labels): improve labels related widgets
- Loading branch information
Raphaël Benitte
committed
Aug 3, 2017
1 parent
e0f5170
commit d3ee798
Showing
13 changed files
with
632 additions
and
495 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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> | ||
) | ||
} | ||
} |
Oops, something went wrong.