Skip to content

Commit

Permalink
resolved issue of package name in block dialog box and same name link
Browse files Browse the repository at this point in the history
  • Loading branch information
BkPankaj committed Jul 28, 2024
1 parent 03c0b43 commit fc55f24
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/blocks/common/base-port/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BasePort: React.FC<BasePortProps> = (props) => {
portClass = props.isInput ? 'custom-input-port': 'custom-output-port';
break;
}

// Different classes based on alignment type. Position varies depending on this.
switch (alignment) {
case PortModelAlignment.RIGHT:
Expand Down
26 changes: 18 additions & 8 deletions frontend/src/core/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ class Editor {
// Process selected input IDs
await Promise.all(data.selectedInputIds.map(async (id: string) => {
const [blockid, name, linkID] = id.split(":");
await this.addComposedBlock('basic.input', name);
await this.addComposedBlock('basic.input', name,blockid);

}));

// Process selected output IDs
await Promise.all(data.selectedOutputIds.map(async (id: string) => {
const [blockid, name, linkID] = id.split(":");
await this.addComposedBlock('basic.output', name);
await this.addComposedBlock('basic.output', name,blockid);

}));
}
Expand All @@ -178,15 +178,25 @@ class Editor {
if(portOptions.type == 'port.input'){
if(linkIds.length == 0){
indexOne++;
let label = `${node.getType()} -> : ${portOptions.label}`;
let label = ``;
var id = `${options.id}:${portOptions.label}:${linkIds}`;
if(node.getType() == 'block.package'){
label = `${node.getType()} -> : ${options.info.name} : ${portOptions.label}`;
}else{
label = `${node.getType()} -> : ${portOptions.label}`;
}
valueOne.push({ indexOne, label, id });
}

}else if(portOptions.type == 'port.output'){
indexTwo++;
let label = `${node.getType()} -> : ${portOptions.label}`;
let label = ``;
var id = `${options.id}:${portOptions.label}:${linkIds}`;
if(node.getType() == 'block.package'){
label = `${node.getType()} -> : ${options.info.name} : ${portOptions.label}`;
}else{
label = `${node.getType()} -> : ${portOptions.label}`;
}
valueTwo.push({ indexTwo, label, id });
}

Expand Down Expand Up @@ -268,7 +278,7 @@ class Editor {
}
}

public nullLinkNodes(type:string, name: string){
public nullLinkNodes(type:string, name: string,blockID:string){
// Get all nodes from the model
const nodes = this.activeModel.getNodes();

Expand All @@ -279,7 +289,7 @@ class Editor {

// Iterate over each port to check if the name matches the given port name
for (const port of Object.values(ports)) {
if (port.getOptions().label === name) {
if (port.getOptions().label === name && node.getID() === blockID) {
const link = new DefaultLinkModel();
if(port.getType()== 'port.input'){
link.setTargetPort(port);
Expand All @@ -304,9 +314,9 @@ class Editor {
* Add the given type of block for composed.
* @param name : Name / type of the block to add to model.
*/
public async addComposedBlock(type: string,name: string): Promise<void> {
public async addComposedBlock(type: string,name: string,blockID: string): Promise<void> {
this.blockCount += 1;
const linkID = this.nullLinkNodes(type, name);
const linkID = this.nullLinkNodes(type, name,blockID);
const block = await createComposedBlock(type,name);
if (block) {

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/serialiser/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function getBlocksAndDependencies(model: DiagramModel) {
const dependencies: { [k: string]: Dependency } = {};
// Iterate over all the nodes and separate them into normal blocks and dependency blocks
model.getNodes().forEach((node) => {

console.log("node",node,node.getType())
if (node instanceof BaseModel) {
const block = {
id: node.getID(),
Expand Down

0 comments on commit fc55f24

Please sign in to comment.