diff --git a/frontend/src/components/BlockContextMenu.vue b/frontend/src/components/BlockContextMenu.vue index 9b9823bb6..ae99346ab 100644 --- a/frontend/src/components/BlockContextMenu.vue +++ b/frontend/src/components/BlockContextMenu.vue @@ -10,6 +10,7 @@ import type Block from "@/block"; import ContextMenu from "@/components/ContextMenu.vue"; import NewBlockTemplate from "@/components/Modals/NewBlockTemplate.vue"; import NewComponent from "@/components/Modals/NewComponent.vue"; +import webComponent from "@/data/webComponent"; import useBuilderStore from "@/stores/builderStore"; import useCanvasStore from "@/stores/canvasStore"; import useComponentStore from "@/stores/componentStore"; @@ -265,6 +266,33 @@ const contextMenuOptions: ContextMenuOption[] = [ condition: () => !block.value.isExtendedFromComponent(), disabled: () => builderStore.readOnlyMode, }, + { + label: "Set as Global Component", + action: () => { + const componentName = block.value.extendedFromComponent || block.value.isChildOfComponent; + if (!componentName) return; + const component = componentStore.getComponent(componentName); + if (!component) return; + webComponent.setValue + .submit({ + name: componentName, + for_web_page: null, + }) + .then(() => { + toast.success("Component is now set as global."); + component.for_web_page = undefined; + componentStore.setComponentMap(component); + }); + }, + condition: () => { + if (!block.value.isExtendedFromComponent()) return false; + const componentName = block.value.extendedFromComponent || block.value.isChildOfComponent; + if (!componentName) return false; + const component = componentStore.getComponent(componentName); + return Boolean(component?.for_web_page); + }, + disabled: () => builderStore.readOnlyMode, + }, { label: "Detach Component", action: () => { diff --git a/frontend/src/components/BuilderAssets.vue b/frontend/src/components/BuilderAssets.vue index 81cf8cbb3..c20ee7350 100644 --- a/frontend/src/components/BuilderAssets.vue +++ b/frontend/src/components/BuilderAssets.vue @@ -14,13 +14,17 @@ draggable="true" :data-component-id="component.component_id" :data-component-name="component.name" + @contextmenu.prevent="(e: MouseEvent) => showContextMenu(e, component)" :class="{ '!border-outline-gray-4': canvasStore.fragmentData.fragmentId === component.name || componentStore.selectedComponent === component.component_id, }">
{{ component.component_name }}
@@ -44,23 +48,31 @@ } " />