mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
Find label based on value
This commit is contained in:
@@ -34,7 +34,6 @@ const Table = ({headers, commenters, onHeaderClickHandler, onRoleChange, onComme
|
||||
<td className="mdl-data-table__cell--non-numeric">
|
||||
<Dropdown
|
||||
value={row.status}
|
||||
label={capitalize(row.status)}
|
||||
placeholder={t('community.status')}
|
||||
onChange={(status) => onCommenterStatusChange(row.id, status)}>
|
||||
<Option value={'ACTIVE'} label={t('community.active')} />
|
||||
@@ -43,8 +42,7 @@ const Table = ({headers, commenters, onHeaderClickHandler, onRoleChange, onComme
|
||||
</td>
|
||||
<td className="mdl-data-table__cell--non-numeric">
|
||||
<Dropdown
|
||||
value={row.roles[0] || t('community.none')}
|
||||
label={capitalize(row.roles[0]) || t('community.none')}
|
||||
value={row.roles[0] || ''}
|
||||
placeholder={t('community.role')}
|
||||
onChange={(role) => onRoleChange(row.id, role)}>
|
||||
<Option value={''} label={t('community.none')} />
|
||||
|
||||
@@ -69,10 +69,10 @@ class Dropdown extends React.Component {
|
||||
const options = React.Children.toArray(this.props.children);
|
||||
const option = options.find((option) => option.props.value === this.props.value);
|
||||
|
||||
if (option.label) {
|
||||
return option.label;
|
||||
} else if(option.value) {
|
||||
return option.value;
|
||||
if (option.props.label) {
|
||||
return option.props.label;
|
||||
} else if(option.props.value) {
|
||||
return option.props.value;
|
||||
} else {
|
||||
return this.props.placeholder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user