Skip to content

Commit

Permalink
Merge pull request #1277 from stakwork/hotfix/schema-filter-invalid
Browse files Browse the repository at this point in the history
fix: filter out invalid schema options
  • Loading branch information
Rassl authored Apr 17, 2024
2 parents 93905f5 + be57974 commit 68d693e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ describe('SourceTypeStep', () => {

it('should filter out deleted node types', async () => {
const mockedSchemaTypes = [
{ type: 'node1', is_deleted: false },
{ type: 'node1', is_deleted: false, ref_id: 'refId1' },
{ type: 'node2', is_deleted: true },
{ type: 'about', is_deleted: false },
{ type: 'schema', is_deleted: false },
{ type: 'about', is_deleted: false, ref_id: 'refId2' },
{ type: 'schema', is_deleted: false, ref_id: 'refId3' },
]

jest.spyOn(fetchSourcesData, 'getNodeSchemaTypes').mockResolvedValue({ schemas: mockedSchemaTypes })
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddItemModal/SourceTypeStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const SourceTypeStep: FC<Props> = ({ skipToStep, allowNextStep, onSelectT
const nodeTypesToHide = ['about', 'schema']

const schemaOptions = data.schemas
.filter((schema) => !nodeTypesToHide.includes(schema.type) && !schema.is_deleted)
.filter((schema) => schema.ref_id && !nodeTypesToHide.includes(schema.type) && !schema.is_deleted)
.map((schema) => ({
label: capitalizeString(schema.type),
value: schema.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const GraphBlueprint: React.FC = () => {
try {
const response = await getSchemaAll()

setSchemaAll(response.schemas.filter((i) => !i.is_deleted))
setSchemaAll(response.schemas.filter((i) => i.ref_id && !i.is_deleted))

setLoading(false)
} catch (error) {
Expand Down

0 comments on commit 68d693e

Please sign in to comment.