mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
* fixes space name being read twice on the space selector screen * fix comment * fix type checks
This commit is contained in:
parent
7eee7cc427
commit
ea92634080
7 changed files with 63 additions and 6 deletions
|
@ -1,5 +1,42 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`removes aria-label when instructed not to announce the space name 1`] = `
|
||||||
|
<Component
|
||||||
|
announceSpaceName={false}
|
||||||
|
space={
|
||||||
|
Object {
|
||||||
|
"id": "",
|
||||||
|
"name": "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<EuiAvatar
|
||||||
|
aria-label=""
|
||||||
|
color="#BFA180"
|
||||||
|
data-test-subj="space-avatar-"
|
||||||
|
initials=""
|
||||||
|
initialsLength={2}
|
||||||
|
name=""
|
||||||
|
size="m"
|
||||||
|
type="space"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
aria-label=""
|
||||||
|
className="euiAvatar euiAvatar--m euiAvatar--space"
|
||||||
|
data-test-subj="space-avatar-"
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"backgroundColor": "#BFA180",
|
||||||
|
"backgroundImage": "none",
|
||||||
|
"color": "#000000",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
title=""
|
||||||
|
/>
|
||||||
|
</EuiAvatar>
|
||||||
|
</Component>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`renders with a space name entirely made of whitespace 1`] = `
|
exports[`renders with a space name entirely made of whitespace 1`] = `
|
||||||
<EuiAvatar
|
<EuiAvatar
|
||||||
color="#DB1374"
|
color="#DB1374"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { shallow } from 'enzyme';
|
import { mount, shallow } from 'enzyme';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SpaceAvatar } from './space_avatar';
|
import { SpaceAvatar } from './space_avatar';
|
||||||
|
|
||||||
|
@ -17,3 +17,8 @@ test('renders with a space name entirely made of whitespace', () => {
|
||||||
const wrapper = shallow(<SpaceAvatar space={{ name: ' ', id: '' }} />);
|
const wrapper = shallow(<SpaceAvatar space={{ name: ' ', id: '' }} />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('removes aria-label when instructed not to announce the space name', () => {
|
||||||
|
const wrapper = mount(<SpaceAvatar space={{ name: '', id: '' }} announceSpaceName={false} />);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EuiAvatar } from '@elastic/eui';
|
import { EuiAvatar } from '@elastic/eui';
|
||||||
import React from 'react';
|
import React, { SFC } from 'react';
|
||||||
import { getSpaceColor, getSpaceInitials, MAX_SPACE_INITIALS } from '../../common';
|
import { getSpaceColor, getSpaceInitials, MAX_SPACE_INITIALS } from '../../common';
|
||||||
import { Space } from '../../common/model/space';
|
import { Space } from '../../common/model/space';
|
||||||
|
|
||||||
|
@ -13,10 +13,11 @@ interface Props {
|
||||||
space: Partial<Space>;
|
space: Partial<Space>;
|
||||||
size?: 's' | 'm' | 'l' | 'xl';
|
size?: 's' | 'm' | 'l' | 'xl';
|
||||||
className?: string;
|
className?: string;
|
||||||
|
announceSpaceName?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SpaceAvatar = (props: Props) => {
|
export const SpaceAvatar: SFC<Props> = (props: Props) => {
|
||||||
const { space, size, ...rest } = props;
|
const { space, size, announceSpaceName, ...rest } = props;
|
||||||
|
|
||||||
const spaceName = space.name ? space.name.trim() : '';
|
const spaceName = space.name ? space.name.trim() : '';
|
||||||
|
|
||||||
|
@ -25,6 +26,10 @@ export const SpaceAvatar = (props: Props) => {
|
||||||
type="space"
|
type="space"
|
||||||
data-test-subj={`space-avatar-${space.id}`}
|
data-test-subj={`space-avatar-${space.id}`}
|
||||||
name={spaceName}
|
name={spaceName}
|
||||||
|
{...!announceSpaceName && {
|
||||||
|
// provide empty aria-label so EUI doesn't try to provide its own
|
||||||
|
'aria-label': '',
|
||||||
|
}}
|
||||||
size={size || 'm'}
|
size={size || 'm'}
|
||||||
initialsLength={MAX_SPACE_INITIALS}
|
initialsLength={MAX_SPACE_INITIALS}
|
||||||
initials={getSpaceInitials(space)}
|
initials={getSpaceInitials(space)}
|
||||||
|
@ -33,3 +38,7 @@ export const SpaceAvatar = (props: Props) => {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SpaceAvatar.defaultProps = {
|
||||||
|
announceSpaceName: true,
|
||||||
|
};
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
// FIXME: need updated typedefs
|
// FIXME: need updated typedefs
|
||||||
|
@ -34,7 +33,9 @@ export const SpaceCard = (props: Props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderSpaceAvatar(space: Space) {
|
function renderSpaceAvatar(space: Space) {
|
||||||
return <SpaceAvatar space={space} size={'l'} />;
|
// not announcing space name here because the title of the EuiCard that the SpaceAvatar lives in is already
|
||||||
|
// announcing it. See https://github.com/elastic/kibana/issues/27748
|
||||||
|
return <SpaceAvatar space={space} size={'l'} announceSpaceName={false} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSpaceDescription(space: Space) {
|
function renderSpaceDescription(space: Space) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ exports[`AdvancedSettingsTitle renders as expected 1`] = `
|
||||||
grow={false}
|
grow={false}
|
||||||
>
|
>
|
||||||
<Component
|
<Component
|
||||||
|
announceSpaceName={true}
|
||||||
space={
|
space={
|
||||||
Object {
|
Object {
|
||||||
"id": "my-space",
|
"id": "my-space",
|
||||||
|
|
|
@ -141,6 +141,7 @@ exports[`SpacesGridPage renders as expected 1`] = `
|
||||||
exports[`SpacesGridPage renders the list of spaces 1`] = `
|
exports[`SpacesGridPage renders the list of spaces 1`] = `
|
||||||
Array [
|
Array [
|
||||||
<Component
|
<Component
|
||||||
|
announceSpaceName={true}
|
||||||
size="s"
|
size="s"
|
||||||
space={
|
space={
|
||||||
Object {
|
Object {
|
||||||
|
@ -181,6 +182,7 @@ Array [
|
||||||
</EuiAvatar>
|
</EuiAvatar>
|
||||||
</Component>,
|
</Component>,
|
||||||
<Component
|
<Component
|
||||||
|
announceSpaceName={true}
|
||||||
size="s"
|
size="s"
|
||||||
space={
|
space={
|
||||||
Object {
|
Object {
|
||||||
|
@ -220,6 +222,7 @@ Array [
|
||||||
</EuiAvatar>
|
</EuiAvatar>
|
||||||
</Component>,
|
</Component>,
|
||||||
<Component
|
<Component
|
||||||
|
announceSpaceName={true}
|
||||||
size="s"
|
size="s"
|
||||||
space={
|
space={
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -7,6 +7,7 @@ exports[`NavControlPopover renders without crashing 1`] = `
|
||||||
<SpacesGlobalNavButton
|
<SpacesGlobalNavButton
|
||||||
linkIcon={
|
linkIcon={
|
||||||
<Unknown
|
<Unknown
|
||||||
|
announceSpaceName={true}
|
||||||
className="spaceNavGraphic"
|
className="spaceNavGraphic"
|
||||||
size="s"
|
size="s"
|
||||||
space={
|
space={
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue