-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Lens] update default legend size to medium #130336
Changes from 13 commits
1bd3e8a
348b793
a6449c6
43011c6
a43e87a
f50405c
bacdef6
07b6ba4
75e5770
cbd7483
f7079d2
9e97779
6e87e68
e252436
c018293
ce369ec
1be5bbf
538742a
7f879f1
0efec68
17140fc
b876e1a
8d47281
0089aa4
44ea016
180c5e7
ecb8604
ea1218e
0c019bf
cfbed11
70d8605
01ba9b7
7c8d259
befa54f
127fbd4
7b44734
0e3a30d
922b5a9
3a3cf3a
43a69e9
bf828cb
8c28bbc
c4f118d
58b4dcd
eb4588f
3332ce1
701a66c
cd85c83
cee8d53
9ee0704
bc69ec8
d612e4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { LegendSizeSettings } from './legend_size_settings'; | ||
import { LegendSizes, DEFAULT_LEGEND_SIZE } from '@kbn/visualizations-plugin/public'; | ||
import { EuiSuperSelect } from '@elastic/eui'; | ||
import { shallow } from 'enzyme'; | ||
|
||
describe('legend size settings', () => { | ||
it('select is disabled if not vertical legend', () => { | ||
const instance = shallow( | ||
<LegendSizeSettings | ||
legendSize={undefined} | ||
onLegendSizeChange={() => {}} | ||
isVerticalLegend={false} | ||
/> | ||
); | ||
|
||
expect(instance.find(EuiSuperSelect).props().disabled).toBeTruthy(); | ||
}); | ||
|
||
it('reflects current setting in select', () => { | ||
const CURRENT_SIZE = LegendSizes.SMALL; | ||
|
||
const instance = shallow( | ||
<LegendSizeSettings | ||
legendSize={Number(CURRENT_SIZE)} | ||
onLegendSizeChange={() => {}} | ||
isVerticalLegend={true} | ||
/> | ||
); | ||
|
||
expect(instance.find(EuiSuperSelect).props().valueOfSelected).toBe(CURRENT_SIZE.toString()); | ||
}); | ||
|
||
it('allows user to select a new option', () => { | ||
const onSizeChange = jest.fn(); | ||
|
||
const instance = shallow( | ||
<LegendSizeSettings | ||
legendSize={Number(LegendSizes.SMALL)} | ||
onLegendSizeChange={onSizeChange} | ||
isVerticalLegend={true} | ||
/> | ||
); | ||
|
||
const onChange = instance.find(EuiSuperSelect).props().onChange; | ||
|
||
onChange(LegendSizes.EXTRA_LARGE); | ||
onChange(DEFAULT_LEGEND_SIZE); | ||
|
||
expect(onSizeChange).toHaveBeenNthCalledWith(1, Number(LegendSizes.EXTRA_LARGE)); | ||
expect(onSizeChange).toHaveBeenNthCalledWith(2, undefined); | ||
}); | ||
|
||
it('hides "auto" option if visualization not using it', () => { | ||
const getOptions = (legendSize: number | undefined) => | ||
shallow( | ||
<LegendSizeSettings | ||
legendSize={legendSize} | ||
onLegendSizeChange={() => {}} | ||
isVerticalLegend={true} | ||
/> | ||
) | ||
.find(EuiSuperSelect) | ||
.props().options; | ||
|
||
const autoOption = expect.objectContaining({ value: LegendSizes.AUTO }); | ||
expect(getOptions(Number(LegendSizes.AUTO))).toContainEqual(autoOption); | ||
expect(getOptions(undefined)).not.toContainEqual(autoOption); | ||
expect(getOptions(Number(LegendSizes.LARGE))).not.toContainEqual(autoOption); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,13 @@ export const VisualizeConstants = { | |
EDIT_BY_VALUE_PATH: '/edit_by_value', | ||
APP_ID: 'visualize', | ||
}; | ||
|
||
export const LegendSizes = { | ||
AUTO: 0, | ||
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. In the spirit of future-proofing, can we think of any case where someone would actually want a legend size of zero? We could use a different number like cc: @flash1293 |
||
SMALL: 80, | ||
MEDIUM: 130, | ||
LARGE: 180, | ||
EXTRA_LARGE: 230, | ||
} as const; | ||
|
||
export const DEFAULT_LEGEND_SIZE = LegendSizes.MEDIUM; | ||
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. This seemed like the right place to put these for usage in all the vis_types. Still open to input. 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. If we have the legend sizes here, do we still need them in the Lens plugin? https://github.com/elastic/kibana/pull/130336/files#diff-d23e749e762688055d5cdbc52ed902a26a009743d66f901b1568728975bcbb9cR45 |
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.
Adding
visualizations
as a required bundle is the salient change here