refactor(core): log warnings for non-prod node envs

This commit is contained in:
Braks
2022-10-18 19:04:22 +02:00
parent 48366780ce
commit 395fcd2aab
10 changed files with 34 additions and 18 deletions
+5 -4
View File
@@ -36,6 +36,7 @@ import {
parseEdge,
pointToRendererPoint,
updateEdgeAction,
warn,
} from '~/utils'
import { useZoomPanHelper } from '~/composables'
@@ -283,8 +284,8 @@ export default (state: State, getters: ComputedGetters): Actions => {
const missingSource = !sourceNode || typeof sourceNode === 'undefined'
const missingTarget = !targetNode || typeof targetNode === 'undefined'
if (missingSource) console.warn(`[vue-flow]: Couldn't create edge for source id: ${edge.source}; edge id: ${edge.id}`)
if (missingTarget) console.warn(`[vue-flow]: Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
if (missingSource) warn(`Couldn't create edge for source id: ${edge.source}; edge id: ${edge.id}`)
if (missingTarget) warn(`Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
if (missingSource || missingTarget) return res
const storedEdge = getters.getEdge.value(edge.id)
@@ -335,8 +336,8 @@ export default (state: State, getters: ComputedGetters): Actions => {
const missingSource = !sourceNode || typeof sourceNode === 'undefined'
const missingTarget = !targetNode || typeof targetNode === 'undefined'
if (missingSource) console.warn(`[vueflow]: Couldn't create edge for source id: ${edge.source}; edge id: ${edge.id}`)
if (missingTarget) console.warn(`[vueflow]: Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
if (missingSource) warn(`Couldn't create edge for source id: ${edge.source}; edge id: ${edge.id}`)
if (missingTarget) warn(`Couldn't create edge for target id: ${edge.target}; edge id: ${edge.id}`)
if (missingTarget || missingSource) return acc
acc.push(
+2 -2
View File
@@ -1,6 +1,6 @@
import { defaultEdgeTypes, defaultNodeTypes } from './state'
import type { ComputedGetters, GraphEdge, GraphNode, State } from '~/types'
import { getNodesInside, isEdgeVisible } from '~/utils'
import { getNodesInside, isEdgeVisible, warn } from '~/utils'
export default (state: State): ComputedGetters => {
const nodeIds = computed(() => state.nodes.map((n) => n.id))
@@ -61,7 +61,7 @@ export default (state: State): ComputedGetters => {
if (!source || !target) {
state.edges = state.edges.filter((edge) => edge.id !== e.id)
console.warn(`[vue-flow]: Orphaned edge ${e.id} removed.`)
warn(`Orphaned edge ${e.id} removed.`)
return
}