Browse Source

feat: add message when can't add block to the blocks group

Ahmad Kholid 3 years ago
parent
commit
7710388d5e
2 changed files with 13 additions and 2 deletions
  1. 11 1
      src/components/block/BlockGroup.vue
  2. 2 1
      src/locales/en/blocks.json

+ 11 - 1
src/components/block/BlockGroup.vue

@@ -87,6 +87,7 @@
 import { watch } from 'vue';
 import { useI18n } from 'vue-i18n';
 import { nanoid } from 'nanoid';
+import { useToast } from 'vue-toastification';
 import draggable from 'vuedraggable';
 import emitter from '@/lib/mitt';
 import { tasks } from '@/utils/shared';
@@ -101,6 +102,7 @@ const props = defineProps({
 });
 
 const { t } = useI18n();
+const toast = useToast();
 const componentId = useComponentId('blocks-group');
 const block = useEditorBlock(`#${componentId}`, props.editor);
 
@@ -149,7 +151,15 @@ function handleDrop(event) {
 
   const { id, data } = droppedBlock;
 
-  if (excludeBlocks.includes(id)) return;
+  if (excludeBlocks.includes(id)) {
+    toast.error(
+      t('workflow.blocks.blocks-group.cantAdd', {
+        blockName: t(`workflow.blocks.${id}.name`),
+      })
+    );
+
+    return;
+  }
 
   block.data.blocks.push({ id, data, itemId: nanoid(5) });
 }

+ 2 - 1
src/locales/en/blocks.json

@@ -45,7 +45,8 @@
         "name": "Blocks group",
         "groupName": "Group name",
         "description": "Grouping blocks",
-        "dropText": "Drag & drop a block here"
+        "dropText": "Drag & drop a block here",
+        "cantAdd": "Can't add \"{blockName}\" block to the group."
       },
       "trigger": {
         "name": "Trigger",