forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[canvas] Create Expressions Service; remove legacy service (elastic#1…
- Loading branch information
1 parent
7a25a08
commit 41b4945
Showing
21 changed files
with
195 additions
and
160 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
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
32 changes: 0 additions & 32 deletions
32
x-pack/plugins/canvas/public/components/element_content/index.js
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/canvas/public/components/element_content/index.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,27 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { getSelectedPage, getPageById } from '../../state/selectors/workpad'; | ||
import { useExpressionsService } from '../../services'; | ||
import { ElementContent as Component, Props as ComponentProps } from './element_content'; | ||
import { State } from '../../../types'; | ||
|
||
export type Props = Omit<ComponentProps, 'renderFunction' | 'backgroundColor'>; | ||
|
||
export const ElementContent = (props: Props) => { | ||
const expressionsService = useExpressionsService(); | ||
const selectedPageId = useSelector(getSelectedPage); | ||
const backgroundColor = | ||
useSelector((state: State) => getPageById(state, selectedPageId)?.style.background) || ''; | ||
const { renderable } = props; | ||
|
||
const renderFunction = renderable ? expressionsService.getRenderer(renderable.as) : null; | ||
|
||
return <Component {...{ ...props, renderFunction, backgroundColor }} />; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ExpressionsService } from '../../../../../src/plugins/expressions/public'; | ||
|
||
export type CanvasExpressionsService = ExpressionsService; |
Oops, something went wrong.