[8.18] [Lens] Fix inline dimension button label (#215476) (#215722)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Lens] Fix inline dimension button label
(#215476)](https://github.com/elastic/kibana/pull/215476)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Andreana
Malama","email":"72010092+andrimal@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-24T14:35:47Z","message":"[Lens]
Fix inline dimension button label (#215476)\n\n## Summary\n\nFix for
#209696. \n\n<img width=\"368\" alt=\"Screenshot 2025-03-21 at 1 49
14 PM\"\nsrc=\"https://github.com/user-attachments/assets/69052665-a194-459b-9c2a-835f4230a99b\"\n/>\n<img
width=\"381\" alt=\"Screenshot 2025-03-21 at 1 49
53 PM\"\nsrc=\"https://github.com/user-attachments/assets/7cf6b7eb-4d1e-40fc-a28f-597634441eb1\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a3fe0cd46090d5b3210c423469ee424e646eeb5f","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:version","v9.1.0","v8.19.0","v8.18.1","v9.0.1"],"title":"[Lens]
Fix inline dimension button
label","number":215476,"url":"https://github.com/elastic/kibana/pull/215476","mergeCommit":{"message":"[Lens]
Fix inline dimension button label (#215476)\n\n## Summary\n\nFix for
#209696. \n\n<img width=\"368\" alt=\"Screenshot 2025-03-21 at 1 49
14 PM\"\nsrc=\"https://github.com/user-attachments/assets/69052665-a194-459b-9c2a-835f4230a99b\"\n/>\n<img
width=\"381\" alt=\"Screenshot 2025-03-21 at 1 49
53 PM\"\nsrc=\"https://github.com/user-attachments/assets/7cf6b7eb-4d1e-40fc-a28f-597634441eb1\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a3fe0cd46090d5b3210c423469ee424e646eeb5f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215476","number":215476,"mergeCommit":{"message":"[Lens]
Fix inline dimension button label (#215476)\n\n## Summary\n\nFix for
#209696. \n\n<img width=\"368\" alt=\"Screenshot 2025-03-21 at 1 49
14 PM\"\nsrc=\"https://github.com/user-attachments/assets/69052665-a194-459b-9c2a-835f4230a99b\"\n/>\n<img
width=\"381\" alt=\"Screenshot 2025-03-21 at 1 49
53 PM\"\nsrc=\"https://github.com/user-attachments/assets/7cf6b7eb-4d1e-40fc-a28f-597634441eb1\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Marco
Liberati
<dej611@users.noreply.github.com>","sha":"a3fe0cd46090d5b3210c423469ee424e646eeb5f"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Andreana Malama <72010092+andrimal@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-03-24 17:36:27 +01:00 committed by GitHub
parent 373b370506
commit 35786f153d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View file

@ -33,6 +33,7 @@ import {
} from '../../../../types'; } from '../../../../types';
interface EmptyButtonProps { interface EmptyButtonProps {
isInlineEditing: boolean;
columnId: string; columnId: string;
onClick: (id: string) => void; onClick: (id: string) => void;
group: VisualizationDimensionGroupConfig; group: VisualizationDimensionGroupConfig;
@ -56,12 +57,24 @@ const defaultButtonLabels = {
), ),
}; };
const DefaultEmptyButton = ({ columnId, group, onClick }: EmptyButtonProps) => { const defaultInlineButtonLabels = {
ariaLabel: (l: string) =>
i18n.translate('xpack.lens.indexPattern.addColumnAriaLabel.inline', {
defaultMessage: 'Add a field to {groupLabel}',
values: { groupLabel: l },
}),
label: (
<FormattedMessage id="xpack.lens.configure.emptyConfig.inline" defaultMessage="Add a field" />
),
};
const DefaultEmptyButton = ({ isInlineEditing, columnId, group, onClick }: EmptyButtonProps) => {
const { buttonAriaLabel, buttonLabel } = group.labels || {}; const { buttonAriaLabel, buttonLabel } = group.labels || {};
const defaultLabels = isInlineEditing ? defaultInlineButtonLabels : defaultButtonLabels;
return ( return (
<EmptyDimensionButtonInner <EmptyDimensionButtonInner
label={buttonLabel || defaultButtonLabels.label} label={buttonLabel || defaultLabels.label}
ariaLabel={buttonAriaLabel || defaultButtonLabels.ariaLabel(group.groupLabel)} ariaLabel={buttonAriaLabel || defaultLabels.ariaLabel(group.groupLabel)}
dataTestSubj="lns-empty-dimension" dataTestSubj="lns-empty-dimension"
onClick={() => onClick(columnId)} onClick={() => onClick(columnId)}
/> />
@ -98,6 +111,7 @@ export function EmptyDimensionButton({
activeVisualization, activeVisualization,
order, order,
target, target,
isInlineEditing,
}: { }: {
order: [2, number, number, number]; order: [2, number, number, number];
group: VisualizationDimensionGroupConfig; group: VisualizationDimensionGroupConfig;
@ -116,6 +130,7 @@ export function EmptyDimensionButton({
label: string; label: string;
}; };
}; };
isInlineEditing: boolean;
}) { }) {
const [{ dragging }] = useDragDropContext(); const [{ dragging }] = useDragDropContext();
@ -177,6 +192,7 @@ export function EmptyDimensionButton({
columnId: value.columnId, columnId: value.columnId,
onClick, onClick,
group, group,
isInlineEditing,
}; };
return ( return (

View file

@ -644,6 +644,7 @@ export function LayerPanel(props: LayerPanelProps) {
}} }}
onDrop={onDrop} onDrop={onDrop}
indexPatterns={dataViews.indexPatterns} indexPatterns={dataViews.indexPatterns}
isInlineEditing={isInlineEditing}
/> />
) : null} ) : null}
</> </>