-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate Input Control component #22400
Changes from 3 commits
c751868
7673f9d
e56cc0a
e7b6290
1895c33
60d0812
983db3b
f3611c7
571d78c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import React, { Component } from 'react'; | |
import { RangeControlEditor } from './range_control_editor'; | ||
import { ListControlEditor } from './list_control_editor'; | ||
import { getTitle } from '../../editor_utils'; | ||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { | ||
EuiAccordion, | ||
|
@@ -34,7 +35,7 @@ import { | |
EuiSpacer, | ||
} from '@elastic/eui'; | ||
|
||
export class ControlEditor extends Component { | ||
class ControlEditorUi extends Component { | ||
|
||
changeLabel = (evt) => { | ||
this.props.handleLabelChange(this.props.controlIndex, evt); | ||
|
@@ -101,7 +102,7 @@ export class ControlEditor extends Component { | |
<EuiForm> | ||
<EuiFormRow | ||
id={labelId} | ||
label="Control Label" | ||
label={<FormattedMessage id="inputControl.editor.controlLabel" defaultMessage="Control Label"/>} | ||
> | ||
<EuiFieldText | ||
value={this.props.controlParams.label} | ||
|
@@ -118,21 +119,21 @@ export class ControlEditor extends Component { | |
return ( | ||
<div> | ||
<EuiButtonIcon | ||
aria-label="Move control up" | ||
aria-label={this.props.intl.formatMessage({ id: 'inputControl.editor.moveControlUpAria', defaultMessage: 'Move control up' })} | ||
color="primary" | ||
onClick={this.moveUpControl} | ||
iconType="sortUp" | ||
data-test-subj={`inputControlEditorMoveUpControl${this.props.controlIndex}`} | ||
/> | ||
<EuiButtonIcon | ||
aria-label="Move control down" | ||
aria-label={this.props.intl.formatMessage({ id: 'inputControl.editor.moveControlDownAria', defaultMessage: 'Move control down' })} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moveControlDownAria => moveControlDownAriaLabel |
||
color="primary" | ||
onClick={this.moveDownControl} | ||
iconType="sortDown" | ||
data-test-subj={`inputControlEditorMoveDownControl${this.props.controlIndex}`} | ||
/> | ||
<EuiButtonIcon | ||
aria-label="Remove control" | ||
aria-label={this.props.intl.formatMessage({ id: 'inputControl.editor.removeControlAria', defaultMessage: 'Remove control' })} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removeControlAria => removeControlAriaLabel |
||
color="danger" | ||
onClick={this.removeControl} | ||
iconType="cross" | ||
|
@@ -161,7 +162,7 @@ export class ControlEditor extends Component { | |
} | ||
} | ||
|
||
ControlEditor.propTypes = { | ||
ControlEditorUi.propTypes = { | ||
controlIndex: PropTypes.number.isRequired, | ||
controlParams: PropTypes.object.isRequired, | ||
handleLabelChange: PropTypes.func.isRequired, | ||
|
@@ -179,3 +180,5 @@ ControlEditor.propTypes = { | |
})).isRequired, | ||
handleParentChange: PropTypes.func.isRequired, | ||
}; | ||
|
||
export const ControlEditor = injectI18n(ControlEditorUi); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import React, { Component } from 'react'; | |
import { ControlEditor } from './control_editor'; | ||
import { addControl, moveControl, newControl, removeControl, setControl } from '../../editor_utils'; | ||
import { getLineageMap, getParentCandidates } from '../../lineage'; | ||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { | ||
EuiButton, | ||
|
@@ -33,7 +34,7 @@ import { | |
EuiSelect, | ||
} from '@elastic/eui'; | ||
|
||
export class ControlsTab extends Component { | ||
class ControlsTabUi extends Component { | ||
|
||
state = { | ||
type: 'list' | ||
|
@@ -138,6 +139,24 @@ export class ControlsTab extends Component { | |
} | ||
|
||
render() { | ||
const { intl } = this.props; | ||
const rangeSliderOption = intl.formatMessage({ | ||
id: 'inputControl.editor.select.rangeDropDown', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rangeDropDown => rangeDropDownOptionLabel. |
||
defaultMessage: 'Range slider' | ||
}); | ||
const optionsListOption = intl.formatMessage({ | ||
id: 'inputControl.editor.select.listDropDown', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. listDropDown => listDropDownOptionLabel |
||
defaultMessage: 'Options list' | ||
}); | ||
const selectAriaLabel = intl.formatMessage({ | ||
id: 'inputControl.editor.select.controlTypeAria', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. controlTypeAria => controlTypeAriaLabel There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add one more namespace for all ids in this file. inputControl.editor.select.controlTypeAria => inputControl.editor.controlsTab.select.controlTypeAriaLabel |
||
defaultMessage: 'Select control type' | ||
}); | ||
const addControlAriaLabel = intl.formatMessage({ | ||
id: 'inputControl.editor.select.addControlAria', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addControlAria => addControlAriaLabel |
||
defaultMessage: 'Add control' | ||
}); | ||
|
||
return ( | ||
<div> | ||
|
||
|
@@ -151,12 +170,12 @@ export class ControlsTab extends Component { | |
> | ||
<EuiSelect | ||
options={[ | ||
{ value: 'range', text: 'Range slider' }, | ||
{ value: 'list', text: 'Options list' }, | ||
{ value: 'range', text: rangeSliderOption }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it is okay to use intl here instead of creating additional variables. I would use variables if translation string is used in multiple times in different places. |
||
{ value: 'list', text: optionsListOption }, | ||
]} | ||
value={this.state.type} | ||
onChange={evt => this.setState({ type: evt.target.value })} | ||
aria-label="Select control type" | ||
aria-label={selectAriaLabel} | ||
/> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
|
@@ -169,9 +188,9 @@ export class ControlsTab extends Component { | |
onClick={this.handleAddControl} | ||
iconType="plusInCircle" | ||
data-test-subj="inputControlEditorAddBtn" | ||
aria-label="Add control" | ||
aria-label={addControlAriaLabel} | ||
> | ||
Add | ||
<FormattedMessage id="inputControl.editor.addButtonLabel" defaultMessage="Add"/> | ||
</EuiButton> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
|
@@ -183,7 +202,9 @@ export class ControlsTab extends Component { | |
} | ||
} | ||
|
||
ControlsTab.propTypes = { | ||
ControlsTabUi.propTypes = { | ||
scope: PropTypes.object.isRequired, | ||
stageEditorParams: PropTypes.func.isRequired | ||
}; | ||
|
||
export const ControlsTab = injectI18n(ControlsTabUi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moveControlUpAria => moveControlUpAriaLabel