Make promotion behave the same as alias button (#54608) (#54704)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Tim Roes 2020-01-14 14:22:57 +01:00 committed by GitHub
parent 428fba3a32
commit 830e8c8923
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View file

@ -1594,7 +1594,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
/>
</EuiSpacer>
<NewVisHelp
addBasePath={[Function]}
onPromotionClicked={[Function]}
promotedTypes={Array []}
>
<EuiText>
@ -3218,7 +3218,7 @@ exports[`NewVisModal should render as expected 1`] = `
/>
</EuiSpacer>
<NewVisHelp
addBasePath={[Function]}
onPromotionClicked={[Function]}
promotedTypes={Array []}
>
<EuiText>

View file

@ -41,7 +41,7 @@ describe('NewVisHelp', () => {
stage: 'production',
},
]}
addBasePath={(url: string) => `testbasepath${url}`}
onPromotionClicked={() => {}}
/>
)
).toMatchInlineSnapshot(`
@ -60,9 +60,9 @@ describe('NewVisHelp', () => {
</p>
<EuiButton
fill={true}
href="testbasepath/my/fancy/new/thing"
iconSide="right"
iconType="popout"
onClick={[Function]}
size="s"
>
Do it now!

View file

@ -21,10 +21,11 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { Fragment } from 'react';
import { EuiText, EuiButton } from '@elastic/eui';
import { VisTypeAliasListEntry } from './type_selection';
import { VisTypeAlias } from '../../../../../../visualizations/public';
interface Props {
promotedTypes: VisTypeAliasListEntry[];
addBasePath: (path: string) => string;
onPromotionClicked: (visType: VisTypeAlias) => void;
}
export function NewVisHelp(props: Props) {
@ -42,7 +43,7 @@ export function NewVisHelp(props: Props) {
<strong>{t.promotion!.description}</strong>
</p>
<EuiButton
href={props.addBasePath(t.aliasUrl)}
onClick={() => props.onPromotionClicked(t)}
fill
size="s"
iconType="popout"

View file

@ -154,7 +154,7 @@ class TypeSelection extends React.Component<TypeSelectionProps, TypeSelectionSta
<EuiSpacer size="m" />
<NewVisHelp
promotedTypes={(visTypes as VisTypeAliasListEntry[]).filter(t => t.promotion)}
addBasePath={this.props.addBasePath}
onPromotionClicked={this.props.onVisTypeSelected}
/>
</React.Fragment>
)}