-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Provide dimension title fallback in case of empty content (#15…
…4368) ## Summary Fixes #151271 This PR is a proposal to provide a fallback title in case the user decides to provide an empty value for dimensions title. <img width="1230" alt="Screenshot 2023-06-14 at 12 05 46" src="https://github.com/elastic/kibana/assets/924948/521d00db-4c1e-4aff-a142-086fa3456884"> <img width="1238" alt="Screenshot 2023-06-14 at 12 05 35" src="https://github.com/elastic/kibana/assets/924948/9a272fac-02e6-4585-81d1-5e0b2686eaf1"> Note that this applies only to the presentation of the dimension button, but the title remains as empty space in the configuration itself. Tests added with testing-library. ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
15 changed files
with
165 additions
and
67 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/plugins/visualization_ui_components/public/components/dimension_buttons/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const emptyTitleText = i18n.translate('visualizationUiComponents.emptyTitle', { | ||
defaultMessage: '[Untitled]', | ||
}); |
50 changes: 50 additions & 0 deletions
50
...visualization_ui_components/public/components/dimension_buttons/dimension_button.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import React from 'react'; | ||
import { DimensionButton, DimensionButtonProps } from './dimension_button'; | ||
|
||
describe('DimensionButton', () => { | ||
function getDefaultProps(): Omit<DimensionButtonProps, 'label' | 'children'> { | ||
return { | ||
groupLabel: 'myGroup', | ||
onClick: jest.fn(), | ||
onRemoveClick: jest.fn(), | ||
accessorConfig: { columnId: '1' }, | ||
message: undefined, | ||
}; | ||
} | ||
it('should fallback to the empty title if the dimension label is made of an empty string', () => { | ||
render( | ||
<DimensionButton {...getDefaultProps()} label=""> | ||
<div /> | ||
</DimensionButton> | ||
); | ||
expect(screen.getByTitle('Edit [Untitled] configuration')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should fallback to the empty title if the dimension label is made up of whitespaces only', () => { | ||
render( | ||
<DimensionButton {...getDefaultProps()} label=" "> | ||
<div /> | ||
</DimensionButton> | ||
); | ||
expect(screen.getByTitle('Edit [Untitled] configuration')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not fallback to the empty title if the dimension label has also valid chars beside whitespaces', () => { | ||
render( | ||
<DimensionButton {...getDefaultProps()} label="aaa "> | ||
<div /> | ||
</DimensionButton> | ||
); | ||
expect(screen.getByTitle('Edit aaa configuration')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/plugins/visualization_ui_components/public/components/dimension_buttons/trigger.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import React from 'react'; | ||
import { DimensionTrigger } from './trigger'; | ||
|
||
describe('DimensionTrigger', () => { | ||
it('should fallback to the empty title if the dimension label is made of an empty string', () => { | ||
render(<DimensionTrigger id="dimensionEmpty" label="" />); | ||
expect(screen.queryByText('[Untitled]')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should fallback to the empty title if the dimension label is made up of whitespaces only', () => { | ||
render(<DimensionTrigger id="dimensionEmpty" label=" " />); | ||
expect(screen.queryByText('[Untitled]')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not fallback to the empty title if the dimension label has also valid chars beside whitespaces', () => { | ||
render(<DimensionTrigger id="dimensionEmpty" label="aaa " />); | ||
expect(screen.queryByText('aaa')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.