Skip to content

Commit

Permalink
fix(api): rename node must update node ref. (#3610)
Browse files Browse the repository at this point in the history
1. Description
1. Related issues
1. About tests
1. Mentions

@ovh/cds
  • Loading branch information
sguiheux authored and bnjjj committed Nov 19, 2018
1 parent 9633e11 commit e86c5f4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
2 changes: 2 additions & 0 deletions engine/api/workflow/dao.go
Expand Up @@ -616,6 +616,8 @@ func RenameNode(db gorp.SqlExecutor, w *sdk.Workflow) error {
for i := range nodes {
if nodes[i].Name == "" {
nodesToNamed = append(nodesToNamed, nodes[i])
} else {
nodes[i].Ref = nodes[i].Name
}

switch nodes[i].Type {
Expand Down
4 changes: 2 additions & 2 deletions ui/package.json
Expand Up @@ -51,8 +51,8 @@
"ansi_up": "^3.0.0",
"codemirror": "^5.22.0",
"core-js": "^2.4.1",
"d3": "3.5.17",
"dagre-d3": "https://github.com/sguiheux/dagre-d3/tarball/reworkDependencies",
"d3": "^4.12.2",
"dagre-d3": "^0.6.1",
"diff": "^3.4.0",
"dragula": "^3.7.2",
"duration-js": "^3.9.2",
Expand Down
Expand Up @@ -96,6 +96,18 @@ export class WorkflowWNodeSidebarEditComponent implements OnInit {
return;
}
node.name = this.node.name;
// Update join
if (clonedWorkflow.workflow_data.joins) {
clonedWorkflow.workflow_data.joins.forEach( j => {
for (let i = 0; i < j.parents.length; i++) {
if (j.parents[i].parent_id === node.id) {
j.parents[i].parent_name = node.name;
break;
}
}
});
}

this.updateWorkflow(clonedWorkflow, null);
}

Expand Down
13 changes: 8 additions & 5 deletions ui/src/app/shared/workflow/sidebar/edit-node/sidebar.edit.html
Expand Up @@ -7,11 +7,14 @@ <h3 class="ui header ml5">
<ng-container *ngIf="node.type === 'pipeline' || node.type === 'fork'">
<div class="content">
<ng-container *ngIf="!displayInputName">
<span>{{node.name}}</span>
<a class="inline pointing ml5" (click)="openRenameArea()"
*ngIf="workflow.permission === permissionEnum.READ_WRITE_EXECUTE">
<i class="pencil icon float"></i>
</a>
<div class="line">
<span class="name" title="{{node.name}}">{{node.name}}</span>
<a class="toto inline pointing ml5" (click)="openRenameArea()"
*ngIf="workflow.permission === permissionEnum.READ_WRITE_EXECUTE">
<i class="pencil icon float"></i>
</a>
</div>

</ng-container>
<ng-container *ngIf="displayInputName">
<div class="ui fluid mini action input">
Expand Down
10 changes: 10 additions & 0 deletions ui/src/app/shared/workflow/sidebar/edit-node/sidebar.edit.scss
Expand Up @@ -14,6 +14,16 @@

.content {
width: 100%;
.line {
display: flex;

.name {
max-width: 140px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.edit-menu {
&:hover {
Expand Down
5 changes: 0 additions & 5 deletions ui/src/app/views/workflow/graph/workflow.graph.component.ts
Expand Up @@ -160,11 +160,6 @@ export class WorkflowGraphComponent implements AfterViewInit {
// Add our custom arrow (a hollow-point)
this.createCustomArrow();

// Setup transition
this.g.graph().transition = (selection: d3.Selection<any>): d3.Transition<any> => {
return selection.transition().duration(100);
};

// Run the renderer. This is what draws the final graph.
this.render(d3.select('svg g'), this.g);

Expand Down

0 comments on commit e86c5f4

Please sign in to comment.