3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- import React from 'react' ;
7
- import { EuiFlexGroup , EuiFlexItem , EuiCard } from '@elastic/eui' ;
8
- import { IComponent } from '../../../component_types' ;
6
+ import React , { useContext } from 'react' ;
7
+ import {
8
+ EuiFlexGroup ,
9
+ EuiFlexItem ,
10
+ EuiCard ,
11
+ EuiText ,
12
+ EuiTitle ,
13
+ EuiButtonIcon ,
14
+ } from '@elastic/eui' ;
15
+ import { rfContext } from '../../../store' ;
16
+ import { IComponentData } from '../../../component_types' ;
9
17
import { InputHandle } from './input_handle' ;
10
18
import { OutputHandle } from './output_handle' ;
11
19
12
20
interface WorkspaceComponentProps {
13
- data : IComponent ;
21
+ data : IComponentData ;
14
22
}
15
23
16
24
/**
@@ -20,18 +28,43 @@ interface WorkspaceComponentProps {
20
28
*/
21
29
export function WorkspaceComponent ( props : WorkspaceComponentProps ) {
22
30
const component = props . data ;
31
+ const { deleteNode } = useContext ( rfContext ) ;
23
32
24
33
return (
25
- < EuiCard title = { component . label } >
34
+ < EuiCard
35
+ textAlign = "left"
36
+ title = {
37
+ < EuiFlexGroup direction = "row" justifyContent = "spaceBetween" >
38
+ < EuiFlexItem grow = { false } >
39
+ < EuiTitle size = "s" >
40
+ < h3 > { component . label } </ h3 >
41
+ </ EuiTitle >
42
+ </ EuiFlexItem >
43
+ < EuiFlexItem grow = { false } >
44
+ < EuiButtonIcon
45
+ iconType = "trash"
46
+ onClick = { ( ) => {
47
+ deleteNode ( component . id ) ;
48
+ } }
49
+ aria-label = "Delete"
50
+ />
51
+ </ EuiFlexItem >
52
+ </ EuiFlexGroup >
53
+ }
54
+ >
26
55
< EuiFlexGroup direction = "column" >
56
+ < EuiFlexItem >
57
+ < EuiText size = "s" color = "subdued" >
58
+ { component . description }
59
+ </ EuiText >
60
+ </ EuiFlexItem >
27
61
{ component . inputs ?. map ( ( input , index ) => {
28
62
return (
29
63
< EuiFlexItem key = { index } >
30
64
< InputHandle input = { input } data = { component } />
31
65
</ EuiFlexItem >
32
66
) ;
33
67
} ) }
34
- { /* TODO: finalize from UX what we show in the component itself. Readonly fields? Configure in the component JSON definition? */ }
35
68
{ component . outputs ?. map ( ( output , index ) => {
36
69
return (
37
70
< EuiFlexItem key = { index } >
0 commit comments