Skip to content

Commit

Permalink
fix(unique-node-types): node types in dropdown should be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Sep 21, 2024
1 parent e2b5f4f commit 8f02059
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ export const ToNode: FC<Props> = ({ onSelect, dataTestId, edgeLink, hideSelectAl
const schemaOptions = data.schemas
.filter((schema) => !schema.is_deleted && schema.type)
.map((schema) =>
schema?.type === 'thing'
schema.type === 'thing'
? { label: 'No Parent', value: schema.type }
: {
label: capitalizeFirstLetter(schema.type),
value: schema.type,
},
)
.filter((option, index, self) => index === self.findIndex((o) => o.value === option.value))

const allOption = { label: 'Select all', value: 'all' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ const fetchAndSetOptions = async (
(schema) => !schema.is_deleted && schema.type && (!filterFunc || filterFunc(schema)),
)

const options = filteredSchemas.map((schema) =>
schema.type === 'thing'
? { label: 'No Parent', value: schema.type }
: { label: capitalizeFirstLetter(schema.type), value: schema.type },
)
const options = filteredSchemas
.map((schema) =>
schema.type === 'thing'
? { label: 'No Parent', value: schema.type }
: { label: capitalizeFirstLetter(schema.type), value: schema.type },
)
.filter((option, index, self) => index === self.findIndex((o) => o.value === option.value))

setOptions(options)
} catch (error) {
Expand Down

0 comments on commit 8f02059

Please sign in to comment.