Skip to content

Commit

Permalink
fix: links between blocks on move
Browse files Browse the repository at this point in the history
  • Loading branch information
IkbelTalebHssan committed Oct 31, 2024
1 parent d5fc8fa commit f8edf63
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api/src/channel/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { SettingCreateDto } from '@/setting/dto/setting.dto';

export type ChannelSetting<N extends string = string> = Omit<
Expand Down
16 changes: 15 additions & 1 deletion api/src/chat/repositories/block.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,26 @@ export class BlockRepository extends BaseRepository<
Block,
'findOneAndUpdate'
>,
_criteria: TFilterQuery<Block>,
criteria: TFilterQuery<Block>,
_updates:
| UpdateWithAggregationPipeline
| UpdateQuery<Document<Block, any, any>>,
): Promise<void> {
const updates: BlockUpdateDto = _updates?.['$set'];
if (updates?.category) {
const movedBlockId = criteria._id;

// Find and update blocks that reference the moved block
await this.model.updateMany(
{ nextBlocks: movedBlockId },
{ $pull: { nextBlocks: movedBlockId } },
);

await this.model.updateMany(
{ attachedBlock: movedBlockId },
{ $set: { attachedBlock: null } },
);
}

this.checkDeprecatedAttachmentUrl(updates);
}
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/channels/live-chat-tester/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import {
DEFAULT_LIVE_CHAT_TEST_SETTINGS,
LIVE_CHAT_TEST_GROUP_NAME,
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/channels/offline/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { DEFAULT_OFFLINE_SETTINGS, OFFLINE_GROUP_NAME } from './settings';

declare global {
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/helpers/core-nlu/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { CORE_NLU_HELPER_GROUP, CORE_NLU_HELPER_SETTINGS } from './settings';

declare global {
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/helpers/core-nlu/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { HelperSetting } from '@/helper/types';
import { SettingType } from '@/setting/schemas/types';

Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/helpers/ollama/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { OLLAMA_HELPER_GROUP, OLLAMA_HELPER_SETTINGS } from './settings';

declare global {
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/helpers/ollama/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { HelperSetting } from '@/helper/types';
import { SettingType } from '@/setting/schemas/types';

Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/plugins/ollama/index.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { Injectable } from '@nestjs/common';

import { Block } from '@/chat/schemas/block.schema';
Expand Down
8 changes: 8 additions & 0 deletions api/src/extensions/plugins/ollama/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { PluginSetting } from '@/plugins/types';
import { SettingType } from '@/setting/schemas/types';

Expand Down
8 changes: 8 additions & 0 deletions api/src/helper/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { SettingCreateDto } from '@/setting/dto/setting.dto';

import BaseHelper from './lib/base-helper';
Expand Down
8 changes: 8 additions & 0 deletions api/src/setting/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { SettingByType } from './schemas/types';
import { DEFAULT_SETTINGS } from './seeds/setting.seed-model';

Expand Down
14 changes: 13 additions & 1 deletion frontend/src/components/visual-editor/v2/Diagrams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ const Diagrams = () => {
}
};
const handleMoveButton = () => {
const selectedEntities = engine?.getModel().getSelectedEntities();
const selectedEntities = engine?.getModel().getSelectedEntities().reverse();
const ids = selectedEntities?.map((model) => model.getID());

if (ids && selectedEntities) {
Expand Down Expand Up @@ -453,10 +453,22 @@ const Diagrams = () => {

if (ids) {
for (const blockId of ids) {
const block = getBlockFromCache(blockId);
const updatedNextBlocks = block?.nextBlocks?.filter((nextBlockId) =>
ids.includes(nextBlockId),
);
const updatedAttachedBlock = ids.includes(
block?.attachedBlock as string,
)
? block?.attachedBlock
: null;

await updateBlock({
id: blockId,
params: {
category: newCategoryId,
nextBlocks: updatedNextBlocks,
attachedBlock: updatedAttachedBlock,
},
});
}
Expand Down

0 comments on commit f8edf63

Please sign in to comment.