1717 :disable-collapse =" COMPONENT_TYPES_ROOT .has (component .type )"
1818 :no-nested-space =" COMPONENT_TYPES_ROOT .has (component .type )"
1919 :collapsed =" isOutsideActivePage "
20+ :right-click-options =" rightClickDropdownOptions "
21+ :dropdown-options ="
22+ component ?.type === ' blueprints_blueprint' &&
23+ isDeleteAllowed (props .componentId )
24+ ? rightClickDropdownOptions
25+ : undefined
26+ "
2027 @select =" select "
28+ @dropdown-select =" handleDropdownSelect ($event )"
2129 @dragover =" handleDragOver "
2230 @dragstart =" handleDragStart "
2331 @dragend =" handleDragEnd "
5361 :component-id =" childComponent .id "
5462 :query =" query "
5563 @expand-branch =" expand "
64+ @delete =" $emit (' delete' , $event )"
5665 />
5766 </template >
5867 </BuilderTree >
@@ -83,6 +92,7 @@ import {
8392 COMPONENT_TYPES_TOP_LEVEL ,
8493} from " @/constants/component" ;
8594import WdsIcon from " @/wds/WdsIcon.vue" ;
95+ import type { WdsDropdownMenuOption } from " @/wds/WdsDropdownMenu.vue" ;
8696
8797const props = defineProps ({
8898 componentId: { type: String , required: true },
@@ -91,6 +101,9 @@ const props = defineProps({
91101
92102const treeBranch = ref <ComponentPublicInstance <typeof BuilderTree >>();
93103
104+ const rightClickDropdownOptions: WdsDropdownMenuOption [] = [
105+ { label: " Delete" , value: " delete" , icon: " trash-2" },
106+ ];
94107const wf = inject (injectionKeys .core );
95108const wfbm = inject (injectionKeys .builderManager );
96109const selected = computed (() => wfbm .isComponentIdSelected (props .componentId ));
@@ -101,11 +114,12 @@ const {
101114 moveComponent,
102115 goToComponentParentPage,
103116 isDraggingAllowed,
117+ isDeleteAllowed,
104118} = useComponentActions (wf , wfbm , tracking );
105119const { getComponentInfoFromDrag, removeInsertionCandidacy, isParentSuitable } =
106120 useDragDropComponent (wf );
107121const { isComponentVisible } = useEvaluator (wf );
108- const emit = defineEmits ([" expandBranch" ]);
122+ const emits = defineEmits ([" expandBranch" , " delete " ]);
109123
110124const q = computed (() => props .query ?.toLocaleLowerCase () ?? " " );
111125
@@ -145,7 +159,7 @@ async function select(ev: MouseEvent | KeyboardEvent) {
145159function expand() {
146160 if (! treeBranch .value ) return ;
147161 treeBranch .value .expand ();
148- emit (" expandBranch" );
162+ emits (" expandBranch" );
149163}
150164
151165function scrollToShow() {
@@ -201,6 +215,12 @@ function handleDrop(ev: DragEvent) {
201215 removeInsertionCandidacy (ev );
202216}
203217
218+ function handleDropdownSelect(action : string ) {
219+ if (action === " delete" && isDeleteAllowed (props .componentId )) {
220+ emits (" delete" , props .componentId );
221+ }
222+ }
223+
204224const isOutsideActivePage = computed (() => {
205225 if (! wf .activePageId .value ) return false ;
206226
0 commit comments