|
@@ -1,60 +1,106 @@
|
|
|
<template>
|
|
|
<div class="block-base relative w-48" @dblclick.stop="$emit('edit')">
|
|
|
- <slot name="prepend" />
|
|
|
- <ui-card :class="contentClass" class="z-10 relative block-base__content">
|
|
|
- <slot></slot>
|
|
|
- </ui-card>
|
|
|
- <slot name="append" />
|
|
|
<div
|
|
|
- v-if="!minimap"
|
|
|
- class="absolute bottom-1 transition-transform duration-300 pt-4 ml-1 menu"
|
|
|
+ class="top-0 w-full absolute block-menu-container hidden"
|
|
|
+ style="transform: translateY(-100%)"
|
|
|
>
|
|
|
- <div
|
|
|
- class="bg-accent dark:bg-gray-100 dark:text-black text-white rounded-lg flex items-center"
|
|
|
- >
|
|
|
+ <div class="inline-flex items-center dark:text-gray-300 block-menu">
|
|
|
<button
|
|
|
- v-if="!hideEdit"
|
|
|
- class="px-3 focus:ring-0 py-2"
|
|
|
- title="Edit block"
|
|
|
- @click="$emit('edit')"
|
|
|
- >
|
|
|
- <v-remixicon size="20" name="riPencilLine" />
|
|
|
- </button>
|
|
|
- <hr
|
|
|
- v-if="!hideDelete && !hideEdit"
|
|
|
- class="border-r border-gray-600 h-5"
|
|
|
- />
|
|
|
- <button
|
|
|
- v-if="!hideDelete"
|
|
|
- class="px-3 focus:ring-0 py-2"
|
|
|
+ v-if="!blockData.details?.disableDelete"
|
|
|
title="Delete block"
|
|
|
@click.stop="$emit('delete')"
|
|
|
>
|
|
|
<v-remixicon size="20" name="riDeleteBin7Line" />
|
|
|
</button>
|
|
|
+ <button
|
|
|
+ v-if="!excludeGroupBlocks.includes(blockData.details?.id)"
|
|
|
+ :title="$t('workflow.blocks.base.moveToGroup')"
|
|
|
+ draggable="true"
|
|
|
+ class="cursor-move"
|
|
|
+ @dragstart="handleStartDrag"
|
|
|
+ @mousedown.stop
|
|
|
+ >
|
|
|
+ <v-remixicon name="riDragDropLine" size="20" />
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-if="blockData.details?.id !== 'trigger'"
|
|
|
+ title="Enable/Disable block"
|
|
|
+ @click.stop="$emit('update', { disableBlock: !data.disableBlock })"
|
|
|
+ >
|
|
|
+ <v-remixicon
|
|
|
+ size="20"
|
|
|
+ :name="data.disableBlock ? 'riToggleLine' : 'riToggleFill'"
|
|
|
+ />
|
|
|
+ </button>
|
|
|
+ <button title="Run workflow from here" @click.stop="runWorkflow">
|
|
|
+ <v-remixicon size="20" name="riPlayLine" />
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-if="!blockData.details?.disableEdit"
|
|
|
+ title="Edit block"
|
|
|
+ @click="$emit('edit')"
|
|
|
+ >
|
|
|
+ <v-remixicon size="20" name="riPencilLine" />
|
|
|
+ </button>
|
|
|
<slot name="action" />
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <slot name="prepend" />
|
|
|
+ <ui-card :class="contentClass" class="z-10 relative block-base__content">
|
|
|
+ <slot></slot>
|
|
|
+ </ui-card>
|
|
|
+ <slot name="append" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-defineProps({
|
|
|
- hideDelete: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
+import { inject } from 'vue';
|
|
|
+import { excludeGroupBlocks } from '@/utils/shared';
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ contentClass: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
},
|
|
|
- minimap: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
+ blockData: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
- hideEdit: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
+ data: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
- contentClass: {
|
|
|
+ blockId: {
|
|
|
type: String,
|
|
|
default: '',
|
|
|
},
|
|
|
});
|
|
|
-defineEmits(['delete', 'edit']);
|
|
|
+defineEmits(['delete', 'edit', 'update']);
|
|
|
+
|
|
|
+const workflowUtils = inject('workflow-utils', null);
|
|
|
+
|
|
|
+function handleStartDrag(event) {
|
|
|
+ const payload = {
|
|
|
+ data: props.data,
|
|
|
+ fromBlockBasic: true,
|
|
|
+ blockId: props.blockId,
|
|
|
+ id: props.blockData.details.id,
|
|
|
+ };
|
|
|
+
|
|
|
+ event.dataTransfer.setData('block', JSON.stringify(payload));
|
|
|
+}
|
|
|
+function runWorkflow() {
|
|
|
+ if (!workflowUtils) return;
|
|
|
+
|
|
|
+ workflowUtils.executeFromBlock(props.blockId);
|
|
|
+}
|
|
|
</script>
|
|
|
+<style>
|
|
|
+.block-menu {
|
|
|
+ @apply mb-1 bg-box-transparent-2 rounded-md;
|
|
|
+ button {
|
|
|
+ padding-left: 6px;
|
|
|
+ padding-right: 6px;
|
|
|
+ @apply focus:ring-0 py-1 hover:text-primary;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|