Skip to content

Commit 2f50bd2

Browse files
authored
Fix order in node explorer (baserow#4221)
1 parent dbb1bcd commit 2f50bd2

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

premium/backend/tests/baserow_premium_tests/fields/test_ai_field_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ def test_ai_field_type_check_can_filter_by(premium_data_fixture):
12151215

12161216
@pytest.mark.django_db
12171217
@pytest.mark.field_ai
1218-
@pytest.mark.skip
12191218
def test_create_ai_field_with_references(premium_data_fixture):
12201219
"""
12211220
Test if AI field type handler creates appropriate FieldDependency entries.

web-frontend/modules/automation/dataProviderTypes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ export class PreviousNodeDataProviderType extends DataProviderType {
2929

3030
const previousNodeSchema = _.chain(previousNodes)
3131
// Retrieve the associated schema for each node
32-
.map((previousNode) => [
32+
.map((previousNode, index) => [
3333
previousNode,
3434
this.getNodeSchema({ automation, node: previousNode }),
3535
])
3636
// Remove nodes without schema
3737
.filter(([_, schema]) => schema)
38+
.map(([previousNode, schema], index) => [
39+
previousNode,
40+
{ ...schema, order: index },
41+
])
3842
// Add an index number to the schema title for each node of the same
3943
// schema title. For example if we have two "Create a row in Customers"
4044
// nodes, then the schema titles will be:
@@ -46,7 +50,6 @@ export class PreviousNodeDataProviderType extends DataProviderType {
4650
{
4751
...schema,
4852
title: `${schema.title}${index ? ` ${index + 1}` : ''}`,
49-
order: index,
5053
},
5154
])
5255
)

web-frontend/modules/core/utils/dataProviders.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
const transformNode = (node) => ({
2+
name: node.name,
3+
type: node.type === 'array' ? 'array' : 'data',
4+
identifier: node.identifier || node.name,
5+
description: node.description || null,
6+
icon: node.icon || 'iconoir-database',
7+
highlightingColor: null,
8+
example: null,
9+
order: node.order || null,
10+
signature: null,
11+
nodes: node.nodes
12+
? node.nodes.map(transformNode).sort((a, b) => a.order - b.order)
13+
: [],
14+
})
15+
116
/**
217
* Processes a list of data providers to extract and transform their nodes
318
* into a structure compatible with the FormulaInputField component. It also
@@ -20,22 +35,11 @@ export const getDataNodesFromDataProvider = (
2035
const providerNodes = dataProvider.getNodes(applicationContext)
2136

2237
// Recursively transform provider nodes to match FormulaInputField's expected structure
23-
const transformNode = (node) => ({
24-
name: node.name,
25-
type: node.type === 'array' ? 'array' : 'data',
26-
identifier: node.identifier || node.name,
27-
description: node.description || null,
28-
icon: node.icon || 'iconoir-database',
29-
highlightingColor: null,
30-
example: null,
31-
order: node.order || null,
32-
signature: null,
33-
nodes: node.nodes ? node.nodes.map(transformNode) : [],
34-
})
35-
3638
// Ensure providerNodes is an array before processing
3739
if (Array.isArray(providerNodes)) {
38-
return providerNodes.map(transformNode)
40+
return providerNodes
41+
.map(transformNode)
42+
.sort((a, b) => a.order - b.order)
3943
} else {
4044
// If it's a single object, transform and add it
4145
return transformNode(providerNodes)

web-frontend/modules/integrations/core/serviceTypes.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export class CoreHTTPRequestServiceType extends WorkflowActionServiceTypeMixin(
3232
getErrorMessage({ service }) {
3333
// We check undefined because the url is not returned in public mode the
3434
// property is just ignored
35-
if (service !== undefined && service.url !== undefined && !service.url) {
35+
if (
36+
service !== undefined &&
37+
service.url !== undefined &&
38+
!service.url.formula
39+
) {
3640
return this.app.i18n.t('serviceType.errorUrlMissing')
3741
}
3842

@@ -75,15 +79,15 @@ export class CoreSMTPEmailServiceType extends WorkflowActionServiceTypeMixin(
7579
if (
7680
service !== undefined &&
7781
service.from_email !== undefined &&
78-
!service.from_email
82+
!service.from_email.formula
7983
) {
8084
return this.app.i18n.t('serviceType.errorFromEmailMissing')
8185
}
8286

8387
if (
8488
service !== undefined &&
8589
service.to_emails !== undefined &&
86-
!service.to_emails
90+
!service.to_emails.formula
8791
) {
8892
return this.app.i18n.t('serviceType.errorToEmailsMissing')
8993
}

0 commit comments

Comments
 (0)