Skip to content

Commit 80beb2a

Browse files
authored
chore: refactor NodeRef structure in Integrations API (#2972)
We are still using `workflow_*` in the integration object and also in the integrations page. Signed-off-by: Lucas Pinheiro <lucas@superplane.com>
1 parent 458afa0 commit 80beb2a

File tree

10 files changed

+82
-82
lines changed

10 files changed

+82
-82
lines changed

api/swagger/superplane.swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4399,10 +4399,10 @@
43994399
"IntegrationNodeRef": {
44004400
"type": "object",
44014401
"properties": {
4402-
"workflowId": {
4402+
"canvasId": {
44034403
"type": "string"
44044404
},
4405-
"workflowName": {
4405+
"canvasName": {
44064406
"type": "string"
44074407
},
44084408
"nodeId": {

pkg/grpc/actions/organizations/create_integration.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func CreateIntegration(ctx context.Context, registry *registry.Registry, oidcPro
8686
}
8787
}
8888

89-
proto, err := serializeIntegration(registry, newIntegration, []models.WorkflowNodeReference{})
89+
proto, err := serializeIntegration(registry, newIntegration, []models.CanvasNodeReference{})
9090
if err != nil {
9191
return nil, status.Errorf(codes.Internal, "failed to serialize integration: %v", err)
9292
}
@@ -96,7 +96,7 @@ func CreateIntegration(ctx context.Context, registry *registry.Registry, oidcPro
9696
}, nil
9797
}
9898

99-
func serializeIntegration(registry *registry.Registry, instance *models.Integration, nodeRefs []models.WorkflowNodeReference) (*pb.Integration, error) {
99+
func serializeIntegration(registry *registry.Registry, instance *models.Integration, nodeRefs []models.CanvasNodeReference) (*pb.Integration, error) {
100100
integration, err := registry.GetIntegration(instance.AppName)
101101
if err != nil {
102102
return nil, err
@@ -144,10 +144,10 @@ func serializeIntegration(registry *registry.Registry, instance *models.Integrat
144144

145145
for _, nodeRef := range nodeRefs {
146146
proto.Status.UsedIn = append(proto.Status.UsedIn, &pb.Integration_NodeRef{
147-
WorkflowId: nodeRef.WorkflowID.String(),
148-
WorkflowName: nodeRef.WorkflowName,
149-
NodeId: nodeRef.NodeID,
150-
NodeName: nodeRef.NodeName,
147+
CanvasId: nodeRef.CanvasID.String(),
148+
CanvasName: nodeRef.CanvasName,
149+
NodeId: nodeRef.NodeID,
150+
NodeName: nodeRef.NodeName,
151151
})
152152
}
153153

pkg/grpc/actions/organizations/list_integrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ListIntegrations(ctx context.Context, registry *registry.Registry, orgID st
1717

1818
protos := []*pb.Integration{}
1919
for _, integration := range integrations {
20-
proto, err := serializeIntegration(registry, &integration, []models.WorkflowNodeReference{})
20+
proto, err := serializeIntegration(registry, &integration, []models.CanvasNodeReference{})
2121
if err != nil {
2222
return nil, err
2323
}

pkg/grpc/actions/organizations/update_integration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func UpdateIntegration(ctx context.Context, registry *registry.Registry, oidcPro
8383
return nil, status.Error(codes.Internal, "failed to save integration")
8484
}
8585

86-
proto, err := serializeIntegration(registry, instance, []models.WorkflowNodeReference{})
86+
proto, err := serializeIntegration(registry, instance, []models.CanvasNodeReference{})
8787
if err != nil {
8888
log.Errorf("failed to serialize integration %s: %v", instance.ID, err)
8989
return nil, status.Error(codes.Internal, "failed to serialize integration")

pkg/models/integration.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ func ListUnscopedIntegrationWebhooks(tx *gorm.DB, integrationID uuid.UUID) ([]We
113113
return webhooks, nil
114114
}
115115

116-
type WorkflowNodeReference struct {
117-
WorkflowID uuid.UUID
118-
WorkflowName string
119-
NodeID string
120-
NodeName string
116+
type CanvasNodeReference struct {
117+
CanvasID uuid.UUID
118+
CanvasName string
119+
NodeID string
120+
NodeName string
121121
}
122122

123-
func ListIntegrationNodeReferences(integrationID uuid.UUID) ([]WorkflowNodeReference, error) {
124-
var nodeReferences []WorkflowNodeReference
123+
func ListIntegrationNodeReferences(integrationID uuid.UUID) ([]CanvasNodeReference, error) {
124+
var nodeReferences []CanvasNodeReference
125125
err := database.Conn().
126126
Table("workflow_nodes AS wn").
127127
Joins("JOIN workflows AS w ON w.id = wn.workflow_id").
128-
Select("w.id as workflow_id, w.name as workflow_name, wn.node_id as node_id, wn.name as node_name").
128+
Select("w.id as canvas_id, w.name as canvas_name, wn.node_id as node_id, wn.name as node_name").
129129
Where("wn.app_installation_id = ?", integrationID).
130130
Where("wn.deleted_at IS NULL").
131131
Find(&nodeReferences).

pkg/openapi_client/model_integration_node_ref.go

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/protos/organizations/organizations.pb.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/organizations.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ message Integration {
410410
}
411411

412412
message NodeRef {
413-
string workflow_id = 1;
414-
string workflow_name = 2;
413+
string canvas_id = 1;
414+
string canvas_name = 2;
415415
string node_id = 3;
416416
string node_name = 4;
417417
}

web_src/src/api-client/types.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ export type GroupsUpdateGroupResponse = {
577577
};
578578

579579
export type IntegrationNodeRef = {
580-
workflowId?: string;
581-
workflowName?: string;
580+
canvasId?: string;
581+
canvasName?: string;
582582
nodeId?: string;
583583
nodeName?: string;
584584
};

web_src/src/pages/organization/settings/IntegrationDetails.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ export function IntegrationDetails({ organizationId }: IntegrationDetailsProps)
5353
const workflowGroups = useMemo(() => {
5454
if (!integration?.status?.usedIn) return [];
5555

56-
const groups = new Map<string, { workflowName: string; nodes: Array<{ nodeId: string; nodeName: string }> }>();
56+
const groups = new Map<string, { canvasName: string; nodes: Array<{ nodeId: string; nodeName: string }> }>();
5757
integration.status.usedIn.forEach((nodeRef) => {
58-
const workflowId = nodeRef.workflowId || "";
59-
const workflowName = nodeRef.workflowName || workflowId;
58+
const canvasId = nodeRef.canvasId || "";
59+
const canvasName = nodeRef.canvasName || canvasId;
6060
const nodeId = nodeRef.nodeId || "";
6161
const nodeName = nodeRef.nodeName || nodeId;
6262

63-
if (!groups.has(workflowId)) {
64-
groups.set(workflowId, { workflowName, nodes: [] });
63+
if (!groups.has(canvasId)) {
64+
groups.set(canvasId, { canvasName, nodes: [] });
6565
}
66-
groups.get(workflowId)?.nodes.push({ nodeId, nodeName });
66+
groups.get(canvasId)?.nodes.push({ nodeId, nodeName });
6767
});
6868

69-
return Array.from(groups.entries()).map(([workflowId, data]) => ({
70-
workflowId,
71-
workflowName: data.workflowName,
69+
return Array.from(groups.entries()).map(([canvasId, data]) => ({
70+
canvasId,
71+
canvasName: data.canvasName,
7272
nodes: data.nodes,
7373
}));
7474
}, [integration?.status?.usedIn]);
@@ -248,13 +248,13 @@ export function IntegrationDetails({ organizationId }: IntegrationDetailsProps)
248248
<div className="space-y-2">
249249
{workflowGroups.map((group) => (
250250
<button
251-
key={group.workflowId}
252-
onClick={() => window.open(`/${organizationId}/canvases/${group.workflowId}`, "_blank")}
251+
key={group.canvasId}
252+
onClick={() => window.open(`/${organizationId}/canvases/${group.canvasId}`, "_blank")}
253253
className="w-full flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800/50 rounded-md border border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors text-left"
254254
>
255255
<div className="flex-1">
256256
<p className="text-sm font-medium text-gray-800 dark:text-gray-100">
257-
Canvas: {group.workflowName}
257+
Canvas: {group.canvasName}
258258
</p>
259259
<p className="text-xs text-gray-500 dark:text-gray-400 mt-1">
260260
Used in {group.nodes.length} node{group.nodes.length !== 1 ? "s" : ""}:{" "}

0 commit comments

Comments
 (0)