Skip to content
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] Fix usage of EUI after typescript upgrade #45404

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use local fix instead of workaround
  • Loading branch information
wylieconlon committed Sep 11, 2019
commit 885a34537b525bfcf0f75be3c297aaba85c13c07
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ describe('suggestion_panel', () => {
const wrapper = mount(<SuggestionPanel {...defaultProps} />);

wrapper
.find('[data-test-subj="lnsSuggestion-target"]')
.find('[data-test-subj="lnsSuggestion"]')
.first()
.simulate('click');

@@ -116,7 +116,7 @@ describe('suggestion_panel', () => {
const wrapper = mount(<SuggestionPanel {...defaultProps} activeVisualizationId="vis2" />);

wrapper
.find('[data-test-subj="lnsSuggestion-target"]')
.find('[data-test-subj="lnsSuggestion"]')
.first()
.simulate('click');

Original file line number Diff line number Diff line change
@@ -6,14 +6,7 @@

import React, { useState, useEffect } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiIcon,
EuiTitle,
EuiPanel,
EuiIconTip,
EuiToolTip,
EuiKeyboardAccessible,
} from '@elastic/eui';
import { EuiIcon, EuiTitle, EuiPanel, EuiIconTip, EuiToolTip } from '@elastic/eui';
import { toExpression, Ast } from '@kbn/interpreter/common';
import { i18n } from '@kbn/i18n';
import { Action } from './state_management';
@@ -25,6 +18,10 @@ import { debouncedComponent } from '../../debounced_component';

const MAX_SUGGESTIONS_DISPLAYED = 5;

// TODO: Remove this <any> when upstream fix is merged https://github.com/elastic/eui/issues/2329
// eslint-disable-next-line
const EuiPanelFixed = EuiPanel as React.ComponentType<any>;

export interface SuggestionPanelProps {
activeDatasourceId: string | null;
datasourceMap: Record<string, Datasource>;
@@ -68,49 +65,42 @@ const SuggestionPreview = ({

return (
<EuiToolTip content={suggestion.title}>
<EuiPanel
<EuiPanelFixed
className="lnsSuggestionPanel__button"
paddingSize="none"
data-test-subj="lnsSuggestion"
onClick={clickHandler}
>
<EuiKeyboardAccessible>
<div
onClick={clickHandler}
onKeyPress={clickHandler}
data-test-subj="lnsSuggestion-target"
>
{expressionError ? (
<div className="lnsSidebar__suggestionIcon">
<EuiIconTip
size="xxl"
color="danger"
type="cross"
aria-label={i18n.translate('xpack.lens.editorFrame.previewErrorLabel', {
defaultMessage: 'Preview rendering failed',
})}
content={i18n.translate('xpack.lens.editorFrame.previewErrorTooltip', {
defaultMessage: 'Preview rendering failed',
})}
/>
</div>
) : previewExpression ? (
<ExpressionRendererComponent
className="lnsSuggestionChartWrapper"
expression={previewExpression}
onRenderFailure={(e: unknown) => {
// eslint-disable-next-line no-console
console.error(`Failed to render preview: `, e);
setExpressionError(true);
}}
/>
) : (
<div className="lnsSidebar__suggestionIcon">
<EuiIcon size="xxl" type={suggestion.previewIcon} />
</div>
)}
{expressionError ? (
<div className="lnsSidebar__suggestionIcon">
<EuiIconTip
size="xxl"
color="danger"
type="cross"
aria-label={i18n.translate('xpack.lens.editorFrame.previewErrorLabel', {
defaultMessage: 'Preview rendering failed',
})}
content={i18n.translate('xpack.lens.editorFrame.previewErrorTooltip', {
defaultMessage: 'Preview rendering failed',
})}
/>
</div>
) : previewExpression ? (
<ExpressionRendererComponent
className="lnsSuggestionChartWrapper"
expression={previewExpression}
onRenderFailure={(e: unknown) => {
// eslint-disable-next-line no-console
console.error(`Failed to render preview: `, e);
setExpressionError(true);
}}
/>
) : (
<div className="lnsSidebar__suggestionIcon">
<EuiIcon size="xxl" type={suggestion.previewIcon} />
</div>
</EuiKeyboardAccessible>
</EuiPanel>
)}
</EuiPanelFixed>
</EuiToolTip>
);
};