-
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.
[Canvas] Disable datasource UI when expression contains an expression…
… argument (#79369) (#79523) * Disable datasource UI when expression contains an expression argument * Removing unnecessary type coercion
- Loading branch information
1 parent
91eee70
commit ecaee18
Showing
6 changed files
with
155 additions
and
32 deletions.
There are no files selected for viewing
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
93 changes: 93 additions & 0 deletions
93
.../plugins/canvas/public/components/datasource/__stories__/datasource_component.stories.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,93 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { EuiCallOut, EuiText } from '@elastic/eui'; | ||
import React from 'react'; | ||
// @ts-expect-error untyped local | ||
import { DatasourceComponent } from '../datasource_component'; | ||
import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component'; | ||
// @ts-expect-error untyped local | ||
import { Datasource } from '../../../../public/expression_types/datasource'; | ||
|
||
const TestDatasource = ({ args }: any) => ( | ||
<EuiCallOut title="My Test Data Source" iconType="iInCircle"> | ||
<EuiText size="s"> | ||
<p>Hello! I am a datasource with a query arg of: {args.query}</p> | ||
</EuiText> | ||
</EuiCallOut> | ||
); | ||
|
||
const testDatasource = () => ({ | ||
name: 'test', | ||
displayName: 'Test Datasource', | ||
help: 'This is a test data source', | ||
image: 'training', | ||
template: templateFromReactComponent(TestDatasource), | ||
}); | ||
|
||
const wrappedTestDatasource = new Datasource(testDatasource()); | ||
|
||
const args = { | ||
query: ['select * from kibana'], | ||
}; | ||
|
||
storiesOf('components/datasource/DatasourceComponent', module) | ||
.addParameters({ | ||
info: { | ||
inline: true, | ||
styles: { | ||
infoBody: { | ||
margin: 20, | ||
}, | ||
infoStory: { | ||
margin: '40px 60px', | ||
width: '320px', | ||
}, | ||
}, | ||
}, | ||
}) | ||
.add('simple datasource', () => ( | ||
<DatasourceComponent | ||
args={args} | ||
datasources={[wrappedTestDatasource]} | ||
datasource={wrappedTestDatasource} | ||
datasourceDef={{}} | ||
stateArgs={args} | ||
stateDatasource={wrappedTestDatasource} | ||
selectDatasouce={action('selectDatasouce')} | ||
setDatasourceAst={action('setDatasourceAst')} | ||
updateArgs={action('updateArgs')} | ||
resetArgs={action('resetArgs')} | ||
selecting={false} | ||
setSelecting={action('setSelecting')} | ||
previewing={false} | ||
setPreviewing={action('setPreviewing')} | ||
isInvalid={false} | ||
setInvalid={action('setInvalid')} | ||
/> | ||
)) | ||
.add('datasource with expression arguments', () => ( | ||
<DatasourceComponent | ||
args={{ query: [{ name: 'expression' }] }} | ||
datasources={[wrappedTestDatasource]} | ||
datasource={wrappedTestDatasource} | ||
datasourceDef={{}} | ||
stateArgs={{ query: [{ name: 'expression' }] }} | ||
stateDatasource={wrappedTestDatasource} | ||
selectDatasouce={action('selectDatasouce')} | ||
setDatasourceAst={action('setDatasourceAst')} | ||
updateArgs={action('updateArgs')} | ||
resetArgs={action('resetArgs')} | ||
selecting={false} | ||
setSelecting={action('setSelecting')} | ||
previewing={false} | ||
setPreviewing={action('setPreviewing')} | ||
isInvalid={false} | ||
setInvalid={action('setInvalid')} | ||
/> | ||
)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export function getDefaultIndex() { | ||
return Promise.resolve('default-index'); | ||
} |