Skip to content

Commit 350c6a1

Browse files
feat(Labels): add label descriptions
1 parent e7f12c1 commit 350c6a1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/common/components/FeedLabel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class FeedLabel extends React.Component {
3838
color: getComplementaryColor(label.color, 40),
3939
borderColor: getComplementaryColor(label.color, 10)
4040
}}
41+
title={label.description}
4142
>
4243

4344
<div className='labelName'>

lib/manager/components/LabelEditor.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import type {ManagerUserState} from '../../types/reducers'
2222
export default class LabelEditor extends React.Component {
2323
state = {
2424
validation: {
25-
name: true
25+
name: true,
26+
description: true
2627
},
2728
newLabel: {...this.props.label}
2829
}
@@ -42,10 +43,11 @@ export default class LabelEditor extends React.Component {
4243
else return permissions.isApplicationAdmin() || permissions.canAdministerAnOrganization()
4344
}
4445

45-
_onFormChange = ({target}: {target: HTMLInputElement}) => {
46+
_onFormChange = ({target}: {target: HTMLInputElement}, alwaysValid: Boolean) => {
4647
const {name, value, type, checked} = target
48+
4749
const universalValue = type === 'checkbox' ? checked : value
48-
const valid = type === 'checkbox' ? true : universalValue.length > 0
50+
const valid = alwaysValid || universalValue.length
4951

5052
this.setState(
5153
update(this.state, {
@@ -110,6 +112,17 @@ export default class LabelEditor extends React.Component {
110112
<FormControl.Feedback />
111113
<HelpBlock>Required.</HelpBlock>
112114
</FormGroup>
115+
<FormGroup
116+
data-test-id='label-description'
117+
>
118+
<ControlLabel>Description</ControlLabel>
119+
<FormControl
120+
value={newLabel.description}
121+
name={'description'}
122+
onChange={e => this._onFormChange(e, true)}
123+
/>
124+
<FormControl.Feedback />
125+
</FormGroup>
113126
</ListGroupItem>
114127
<ListGroupItem>
115128
<Row>
@@ -139,7 +152,7 @@ export default class LabelEditor extends React.Component {
139152
checked={newLabel.adminOnly}
140153
name={'adminOnly'}
141154
type='checkbox'
142-
onChange={this._onFormChange}
155+
onChange={e => this._onFormChange(e, true)}
143156
/>
144157
</Col>
145158
<Col xs={9}>

0 commit comments

Comments
 (0)