-
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.
Merge branch 'master' of github.com:elastic/kibana into sessions/save…
…-all-sessions
- Loading branch information
Showing
96 changed files
with
2,409 additions
and
232 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
102 changes: 102 additions & 0 deletions
102
examples/expressions_explorer/public/actions_and_expressions2.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,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* and the Server Side Public License, v 1; you may not use this file except in | ||
* compliance with, at your election, the Elastic License or the Server Side | ||
* Public License, v 1. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { | ||
EuiFlexItem, | ||
EuiFlexGroup, | ||
EuiPageBody, | ||
EuiPageContent, | ||
EuiPageContentBody, | ||
EuiPageHeader, | ||
EuiPageHeaderSection, | ||
EuiPanel, | ||
EuiText, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
import { | ||
ExpressionsStart, | ||
ReactExpressionRenderer, | ||
ExpressionsInspectorAdapter, | ||
} from '../../../src/plugins/expressions/public'; | ||
import { ExpressionEditor } from './editor/expression_editor'; | ||
import { UiActionsStart } from '../../../src/plugins/ui_actions/public'; | ||
|
||
interface Props { | ||
expressions: ExpressionsStart; | ||
actions: UiActionsStart; | ||
} | ||
|
||
export function ActionsExpressionsExample2({ expressions, actions }: Props) { | ||
const [expression, updateExpression] = useState( | ||
'button name="click me" href="http://www.google.com" color={var color}' | ||
); | ||
|
||
const [variables, updateVariables] = useState({ | ||
color: 'blue', | ||
}); | ||
|
||
const expressionChanged = (value: string) => { | ||
updateExpression(value); | ||
}; | ||
|
||
const inspectorAdapters = { | ||
expression: new ExpressionsInspectorAdapter(), | ||
}; | ||
|
||
const handleEvents = (event: any) => { | ||
updateVariables({ color: event.value.href === 'http://www.google.com' ? 'red' : 'blue' }); | ||
}; | ||
|
||
return ( | ||
<EuiPageBody> | ||
<EuiPageHeader> | ||
<EuiPageHeaderSection> | ||
<EuiTitle size="l"> | ||
<h1>Actions from expression renderers</h1> | ||
</EuiTitle> | ||
</EuiPageHeaderSection> | ||
</EuiPageHeader> | ||
<EuiPageContent> | ||
<EuiPageContentBody data-test-subj="expressionsVariablesTest"> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiText> | ||
This example is similar to previous one, but clicking the button will rerender the | ||
expression with new set of variables. | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiFlexGroup gutterSize="l"> | ||
<EuiFlexItem> | ||
<EuiPanel data-test-subj="expressionEditor" paddingSize="none" role="figure"> | ||
<ExpressionEditor value={expression} onChange={expressionChanged} /> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel paddingSize="none" role="figure"> | ||
<ReactExpressionRenderer | ||
data-test-subj="expressionsVariablesTestRenderer" | ||
expression={expression} | ||
debug={true} | ||
inspectorAdapters={inspectorAdapters} | ||
variables={variables} | ||
onEvent={handleEvents} | ||
renderError={(message: any) => { | ||
return <div>{message}</div>; | ||
}} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
); | ||
} |
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
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
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
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
Oops, something went wrong.