Skip to content

Commit

Permalink
[Visualizations] Make the icon buttons labels more descriptive (#82585)…
Browse files Browse the repository at this point in the history
… (#83040)

* [Visualizations] Make the icon buttons labels more descriptive on the Vis Editor

* Fix jest test

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
stratoula and kibanamachine authored Nov 10, 2020
1 parent 61e2af3 commit 7be2e92
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions src/plugins/vis_default_editor/public/components/agg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function DefaultEditorAgg({
const showDescription = !isEditorOpen && validState;
const showError = !isEditorOpen && !validState;
const aggName = agg.type?.name;
const schemaTitle = getSchemaByName(schemas, agg.schema).title;
let disabledParams;
let aggError;
// When a Parent Pipeline agg is selected and this agg is the last bucket.
Expand Down Expand Up @@ -163,14 +164,16 @@ function DefaultEditorAgg({

const renderAggButtons = () => {
const actionIcons = [];
const aggTitle = agg.type?.title?.toLowerCase();

if (showError) {
actionIcons.push({
id: 'hasErrors',
color: 'danger',
type: 'alert',
tooltip: i18n.translate('visDefaultEditor.agg.errorsAriaLabel', {
defaultMessage: 'Aggregation has errors',
defaultMessage: '{schemaTitle} {aggTitle} aggregation has errors',
values: { aggTitle, schemaTitle },
}),
dataTestSubj: 'hasErrorsAggregationIcon',
});
Expand All @@ -184,7 +187,8 @@ function DefaultEditorAgg({
type: 'eye',
onClick: () => onToggleEnableAgg(agg.id, false),
tooltip: i18n.translate('visDefaultEditor.agg.disableAggButtonTooltip', {
defaultMessage: 'Disable aggregation',
defaultMessage: 'Disable {schemaTitle} {aggTitle} aggregation',
values: { aggTitle, schemaTitle },
}),
dataTestSubj: 'toggleDisableAggregationBtn disable',
});
Expand All @@ -196,7 +200,8 @@ function DefaultEditorAgg({
type: 'eyeClosed',
onClick: () => onToggleEnableAgg(agg.id, true),
tooltip: i18n.translate('visDefaultEditor.agg.enableAggButtonTooltip', {
defaultMessage: 'Enable aggregation',
defaultMessage: 'Enable {schemaTitle} {aggTitle} aggregation',
values: { aggTitle, schemaTitle },
}),
dataTestSubj: 'toggleDisableAggregationBtn enable',
});
Expand All @@ -206,7 +211,8 @@ function DefaultEditorAgg({
id: 'dragHandle',
type: 'grab',
tooltip: i18n.translate('visDefaultEditor.agg.modifyPriorityButtonTooltip', {
defaultMessage: 'Modify priority by dragging',
defaultMessage: 'Modify priority of {schemaTitle} {aggTitle} by dragging',
values: { aggTitle, schemaTitle },
}),
dataTestSubj: 'dragHandleBtn',
});
Expand All @@ -218,7 +224,8 @@ function DefaultEditorAgg({
type: 'cross',
onClick: () => removeAgg(agg.id),
tooltip: i18n.translate('visDefaultEditor.agg.removeDimensionButtonTooltip', {
defaultMessage: 'Remove dimension',
defaultMessage: 'Remove {schemaTitle} {aggTitle} aggregation',
values: { aggTitle, schemaTitle },
}),
dataTestSubj: 'removeDimensionBtn',
});
Expand Down Expand Up @@ -257,7 +264,7 @@ function DefaultEditorAgg({
</div>
);
};
const schemaTitle = getSchemaByName(schemas, agg.schema).title;

const buttonContent = (
<>
{schemaTitle || agg.schema} {showDescription && <span>{aggDescription}</span>}
Expand Down
14 changes: 9 additions & 5 deletions src/plugins/vis_default_editor/public/components/agg_add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,26 @@ function DefaultEditorAggAdd({
addSchema(schema);
};

const groupNameLabel =
groupName === AggGroupNames.Buckets
? i18n.translate('visDefaultEditor.aggAdd.bucketLabel', { defaultMessage: 'bucket' })
: i18n.translate('visDefaultEditor.aggAdd.metricLabel', { defaultMessage: 'metric' });

const addButton = (
<EuiButtonEmpty
size="xs"
iconType="plusInCircleFilled"
data-test-subj={`visEditorAdd_${groupName}`}
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
aria-label={i18n.translate('visDefaultEditor.aggAdd.addGroupButtonLabel', {
defaultMessage: 'Add {groupNameLabel}',
values: { groupNameLabel },
})}
>
<FormattedMessage id="visDefaultEditor.aggAdd.addButtonLabel" defaultMessage="Add" />
</EuiButtonEmpty>
);

const groupNameLabel =
groupName === AggGroupNames.Buckets
? i18n.translate('visDefaultEditor.aggAdd.bucketLabel', { defaultMessage: 'bucket' })
: i18n.translate('visDefaultEditor.aggAdd.metricLabel', { defaultMessage: 'metric' });

const isSchemaDisabled = (schema: Schema): boolean => {
const count = group.filter((agg) => agg.schema === schema.name).length;
return count >= schema.max;
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -3547,11 +3547,6 @@
"uiActions.triggers.valueClickTitle": "シングルクリック",
"usageCollection.stats.notReadyMessage": "まだ統計が準備できていません。しばらくたってから再試行してください。",
"visDefaultEditor.advancedToggle.advancedLinkLabel": "高度な設定",
"visDefaultEditor.agg.disableAggButtonTooltip": "集約を無効にする",
"visDefaultEditor.agg.enableAggButtonTooltip": "集約を有効にする",
"visDefaultEditor.agg.errorsAriaLabel": "集約にエラーがあります",
"visDefaultEditor.agg.modifyPriorityButtonTooltip": "ドラッグして優先順位を変更します",
"visDefaultEditor.agg.removeDimensionButtonTooltip": "次元を削除",
"visDefaultEditor.agg.toggleEditorButtonAriaLabel": "{schema} エディターを切り替える",
"visDefaultEditor.aggAdd.addButtonLabel": "追加",
"visDefaultEditor.aggAdd.addGroupButtonLabel": "{groupNameLabel} を追加",
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3548,11 +3548,6 @@
"uiActions.triggers.valueClickTitle": "单击",
"usageCollection.stats.notReadyMessage": "统计信息尚未准备就绪。请稍后重试。",
"visDefaultEditor.advancedToggle.advancedLinkLabel": "高级",
"visDefaultEditor.agg.disableAggButtonTooltip": "禁用聚合",
"visDefaultEditor.agg.enableAggButtonTooltip": "启用聚合",
"visDefaultEditor.agg.errorsAriaLabel": "聚合有错误",
"visDefaultEditor.agg.modifyPriorityButtonTooltip": "通过拖动来修改优先级",
"visDefaultEditor.agg.removeDimensionButtonTooltip": "移除维度",
"visDefaultEditor.agg.toggleEditorButtonAriaLabel": "切换 {schema} 编辑器",
"visDefaultEditor.aggAdd.addButtonLabel": "添加",
"visDefaultEditor.aggAdd.addGroupButtonLabel": "添加{groupNameLabel}",
Expand Down

0 comments on commit 7be2e92

Please sign in to comment.