diff --git a/frontend/libs/console/legacy-ce/src/lib/features/DatabaseRelationships/hooks/useCreateTableRelationships/useCreateTableRelationships.ts b/frontend/libs/console/legacy-ce/src/lib/features/DatabaseRelationships/hooks/useCreateTableRelationships/useCreateTableRelationships.ts index fae1777d016..dd032234ee7 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/DatabaseRelationships/hooks/useCreateTableRelationships/useCreateTableRelationships.ts +++ b/frontend/libs/console/legacy-ce/src/lib/features/DatabaseRelationships/hooks/useCreateTableRelationships/useCreateTableRelationships.ts @@ -1,10 +1,6 @@ import { useCallback } from 'react'; import { isObject } from '../../../../components/Common/utils/jsUtils'; import { transformErrorResponse } from '../../../Data/errorUtils'; -// import { -// useAllDriverCapabilities, -// useDriverCapabilities, -// } from '../../../Data/hooks/useDriverCapabilities'; import { useAllDriverCapabilities } from '../../../Data/hooks/useAllDriverCapabilities'; import { Feature } from '../../../DataSource'; import { useMetadataMigration } from '../../../MetadataAPI'; @@ -50,6 +46,18 @@ const defaultCapabilities = { isRemoteSchemaRelationshipSupported: true, }; +const isRemoteRelPresentInPayload = ( + data: ReturnType[] +) => { + const remoteRel = data.find(rel => { + if (rel === 'Not implemented') return false; + + return rel.type.includes('_create_remote_relationship'); + }); + + return !!remoteRel; +}; + const getTargetName = (target: AllowedRelationshipDefinitions['target']) => { if ('toRemoteSchema' in target) return null; @@ -156,7 +164,9 @@ export const useCreateTableRelationships = ( mutate( { query: { - type: 'bulk_atomic', + type: isRemoteRelPresentInPayload(payloads) + ? 'bulk_keep_going' + : 'bulk_atomic', args: payloads, resource_version, }, diff --git a/frontend/libs/console/legacy-ce/src/lib/metadata/reducer.ts b/frontend/libs/console/legacy-ce/src/lib/metadata/reducer.ts index 22a271c604e..4c976d1243b 100644 --- a/frontend/libs/console/legacy-ce/src/lib/metadata/reducer.ts +++ b/frontend/libs/console/legacy-ce/src/lib/metadata/reducer.ts @@ -217,20 +217,22 @@ export const metadataReducer = ( case 'Metadata/ADD_INHERITED_ROLE': return { ...state, - inheritedRoles: [...state.inheritedRoles, action.data], + inheritedRoles: [...(state.inheritedRoles ?? []), action.data], }; case 'Metadata/DELETE_INHERITED_ROLE': return { ...state, inheritedRoles: [ - ...state.inheritedRoles.filter(ir => ir.role_name !== action.data), + ...(state.inheritedRoles ?? []).filter( + ir => ir.role_name !== action.data + ), ], }; case 'Metadata/UPDATE_INHERITED_ROLE': return { ...state, inheritedRoles: [ - ...state.inheritedRoles.map(ir => + ...(state.inheritedRoles ?? []).map(ir => ir.role_name === action.data.role_name ? action.data : ir ), ],