@@ -24,7 +24,7 @@ import { EntityHead, EntityName } from '../styles';
2424import { CtrlClickGo2Source } from '../../../common/CtrlClickHandler/CtrlClickGo2Source' ;
2525import { DiagramContext } from '../../../common' ;
2626import styled from '@emotion/styled' ;
27- import { Button , Item , Menu , MenuItem , Popover } from '@wso2/ui-toolkit' ;
27+ import { Button , Item , Menu , MenuItem , Popover , ThemeColors } from '@wso2/ui-toolkit' ;
2828import { MoreVertIcon } from '../../../../resources' ;
2929import { GraphQLIcon } from '../../../../resources/assets/icons/GraphqlIcon' ;
3030
@@ -68,11 +68,25 @@ const HeaderWrapper = styled.div`
6868 width: 100%;
6969` ;
7070
71+ const ImportedLabel = styled . span `
72+ background-color: ${ ThemeColors . SURFACE_CONTAINER } ;
73+ border-radius: 3px;
74+ color: ${ ThemeColors . ON_SURFACE_VARIANT } ;
75+ font-family: GilmerRegular;
76+ font-size: 10px;
77+ height: 20px;
78+ line-height: 20px;
79+ padding: 0 6px;
80+ margin-left: 8px;
81+ white-space: nowrap;
82+ ` ;
83+
7184export function EntityHeadWidget ( props : ServiceHeadProps ) {
7285 const { engine, node, isSelected } = props ;
7386 const { setFocusedNodeId, onEditNode, goToSource } = useContext ( DiagramContext ) ;
7487
7588 const displayName : string = node . getID ( ) ?. slice ( node . getID ( ) ?. lastIndexOf ( ':' ) + 1 ) ;
89+ const isImported = ! node ?. entityObject ?. editable ;
7690
7791 const [ anchorEl , setAnchorEl ] = useState < HTMLElement | SVGSVGElement > ( null ) ;
7892 const isMenuOpen = Boolean ( anchorEl ) ;
@@ -82,7 +96,7 @@ export function EntityHeadWidget(props: ServiceHeadProps) {
8296 } ;
8397
8498 const onNodeEdit = ( ) => {
85- if ( onEditNode ) {
99+ if ( onEditNode && node ?. entityObject ?. editable ) {
86100 if ( node . isGraphqlRoot ) {
87101 onEditNode ( node . getID ( ) , true ) ;
88102 } else {
@@ -103,13 +117,23 @@ export function EntityHeadWidget(props: ServiceHeadProps) {
103117 }
104118
105119 const menuItems : Item [ ] = [
120+ ...( node ?. entityObject ?. editable ? [
121+ {
122+ id : "edit" ,
123+ label : "Edit" ,
124+ onClick : ( ) => onNodeEdit ( ) ,
125+ } ,
126+ {
127+ id : "goToSource" ,
128+ label : "Source" ,
129+ onClick : ( ) => onGoToSource ( )
130+ }
131+ ] : [ ] ) ,
106132 {
107- id : "edit" ,
108- label : "Edit" ,
109- onClick : ( ) => onNodeEdit ( ) ,
110- } ,
111- { id : "goToSource" , label : "Source" , onClick : ( ) => onGoToSource ( ) } ,
112- { id : "focusView" , label : "Focused View" , onClick : ( ) => onFocusedView ( ) }
133+ id : "focusView" ,
134+ label : "Focused View" ,
135+ onClick : ( ) => onFocusedView ( )
136+ }
113137 ] ;
114138
115139 const isClickable = true ;
@@ -133,12 +157,17 @@ export function EntityHeadWidget(props: ServiceHeadProps) {
133157 </ div >
134158 ) }
135159 < EntityName
136- isClickable = { isClickable }
160+ isClickable = { isClickable && ! isImported }
137161 onClick = { onNodeEdit }
138162 onDoubleClick = { onFocusedView }
139163 >
140164 { displayName }
141165 </ EntityName >
166+ { isImported && (
167+ < ImportedLabel >
168+ Imported Type
169+ </ ImportedLabel >
170+ ) }
142171 </ EntityNameContainer >
143172 < HeaderButtonsContainer >
144173 { /* {selectedNodeId === node.getID() && (
0 commit comments