Skip to content

Commit 0fc0284

Browse files
committed
Add inline error message for when reference is required
1 parent 3d501f1 commit 0fc0284

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

plugins/hubspot/src/components/FieldMapper.tsx

+16-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface FieldMapperProps {
2222
className?: string
2323
height?: number
2424
}
25+
2526
const getInitialSortedFields = (
2627
fields: ManagedCollectionFieldConfig[],
2728
isFieldSelected: (fieldId: string) => boolean
@@ -34,9 +35,17 @@ const getInitialSortedFields = (
3435
if (aIsSelected && !bIsSelected) return -1
3536
if (!aIsSelected && bIsSelected) return 1
3637

37-
// Then sort by whether they are supported fields
38-
if (a.field && !b.field) return -1
39-
if (!a.field && b.field) return 1
38+
// Sort by whether they are supported fields
39+
if (a.field !== null && a.field !== undefined && (b.field === null || b.field === undefined)) return -1
40+
if ((a.field === null || a.field === undefined) && b.field !== null && b.field !== undefined) return 1
41+
42+
// Sort by whether they are null (missing reference)
43+
if (a.field === null && b.field !== null) return -1
44+
if (a.field !== null && b.field === null) return 1
45+
46+
// Sort by whether they are undefined (unsupported fields)
47+
if (a.field === undefined && b.field !== undefined) return 1
48+
if (a.field !== undefined && b.field === undefined) return -1
4049

4150
return 0
4251
})
@@ -93,9 +102,11 @@ export const FieldMapper = ({
93102
disabled={!fieldConfig.field || !isSelected}
94103
placeholder={fieldConfig.originalFieldName}
95104
value={
96-
!fieldConfig.field
105+
fieldConfig.field === undefined
97106
? "Unsupported Field"
98-
: (fieldNameOverrides[fieldConfig.field.id] ?? "")
107+
: fieldConfig.field === null
108+
? "Missing Reference"
109+
: (fieldNameOverrides[fieldConfig.field.id] ?? "")
99110
}
100111
onChange={e => {
101112
assert(fieldConfig.field)

plugins/hubspot/src/hubdb.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ async function getFieldValue(column: Column, cellValue: HubDBCellValue): Promise
125125

126126
/**
127127
* Get the collection field schema for a HubDB column.
128+
* Returns `null` for fields that are supported but can't be synced yet
129+
* Returns `undefined` for fields that are not supported outright
128130
*/
129131
export function getCollectionFieldForHubDBColumn(
130132
column: Column,
@@ -200,7 +202,7 @@ export function getCollectionFieldForHubDBColumn(
200202
}
201203

202204
default:
203-
return null
205+
return undefined
204206
}
205207
}
206208

0 commit comments

Comments
 (0)