-
Notifications
You must be signed in to change notification settings - Fork 51
/
TMMergeOptionsCommon.js
44 lines (40 loc) · 1.46 KB
/
TMMergeOptionsCommon.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
import React from 'react'
import PropTypes from 'prop-types'
import {IGNORE_CHECK, FUZZY, REJECT} from '../../utils/EnumValueUtils'
import {Label} from 'react-bootstrap'
const mergeOptionValues = [IGNORE_CHECK, FUZZY, REJECT]
export const TMMergeOptionsValuePropType = {
differentProject: PropTypes.oneOf(mergeOptionValues).isRequired,
differentDocId: PropTypes.oneOf(mergeOptionValues).isRequired,
differentContext: PropTypes.oneOf(mergeOptionValues).isRequired,
fromImportedTM: PropTypes.oneOf(mergeOptionValues).isRequired
}
export const TMMergeOptionsCallbackPropType = {
onDifferentProjectChange: PropTypes.func.isRequired,
onDifferentDocIdChange: PropTypes.func.isRequired,
onDifferentContextChange: PropTypes.func.isRequired
}
const activeOrDefault =
(isActive, activeStyle) => isActive ? activeStyle : 'default'
export const CopyLabel = ({type, value}) => {
const isActive = value === type
switch (type) {
case IGNORE_CHECK:
return <Label bsStyle={activeOrDefault(isActive, 'success')}>
Copy as Translated
</Label>
case FUZZY:
return <Label bsStyle={activeOrDefault(isActive, 'warning')}>
Copy as Fuzzy
</Label>
case REJECT:
return <Label bsStyle={activeOrDefault(isActive, 'danger')}>
Discard
</Label>
}
return <span />
}
CopyLabel.propTypes = {
type: PropTypes.oneOf([IGNORE_CHECK, FUZZY, REJECT]).isRequired,
value: PropTypes.oneOf([IGNORE_CHECK, FUZZY, REJECT]).isRequired
}