-
Notifications
You must be signed in to change notification settings - Fork 51
/
PriorityDropdown.js
73 lines (72 loc) · 2.19 KB
/
PriorityDropdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react'
import { Component } from 'react'
import { Icon } from '../../../components'
import * as PropTypes from 'prop-types'
import Dropdown from '../../components/Dropdown'
import { MINOR, MAJOR, CRITICAL } from '../../utils/reject-trans-util'
/**
* A Local Editor Dropdown coponent that selects the Priority of a
* translation rejection message
*/
class ProirityDropdown extends Component {
static propTypes = {
textState: PropTypes.string.isRequired,
priority: PropTypes.oneOf(
[
MINOR,
MAJOR,
CRITICAL
]
).isRequired,
priorityChange: PropTypes.func.isRequired
}
constructor (props) {
super(props)
this.state = {
dropdownOpen: false
}
}
toggleDropdown = () => {
this.setState(prevState => ({
dropdownOpen: !prevState.dropdownOpen
}))
}
onPriorityChange = (event) => {
this.props.priorityChange(event)
this.toggleDropdown()
}
render () {
const { textState, priority } = this.props
return (
<span className='PriorityDropdown'>
<Icon name='warning' className='s2'
parentClassName='u-textWarning' />
<span id='PriorityTitle'>Priority</span>
<Dropdown enabled isOpen={this.state.dropdownOpen}
onToggle={this.toggleDropdown}
className='dropdown-menu priority'>
<Dropdown.Button>
<a className='EditorDropdown-item'>
<span className={textState}>{priority}</span>
<Icon className='n1' name='chevron-down' />
</a>
</Dropdown.Button>
<Dropdown.Content>
<ul>
<li className='EditorDropdown-item'
onClick={this.onPriorityChange}>
<span>Minor</span></li>
<li className='EditorDropdown-item'
onClick={this.onPriorityChange}>
<span className='u-textWarning'>Major</span></li>
<li className='EditorDropdown-item'
onClick={this.onPriorityChange}>
<span className='u-textDanger'>Critical</span></li>
</ul>
</Dropdown.Content>
</Dropdown>
</span>
)
}
}
export default ProirityDropdown