Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 error tree number #3741

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import IconHotSpot from "@illa-public/icon-hot-spot"
import { ILLA_MIXPANEL_EVENT_TYPE } from "@illa-public/mixpanel-utils"
import { t } from "i18next"
import { FC, memo } from "react"
import { FC, memo, useMemo } from "react"
import { useDispatch, useSelector } from "react-redux"
import { Badge, BugIcon, Trigger, getColor } from "@illa-design/react"
import { isOpenDebugger } from "@/redux/config/configSelector"
Expand All @@ -13,9 +13,18 @@ const DebugButton: FC = () => {
const debuggerData = useSelector(getExecutionError)
const debuggerVisible = useSelector(isOpenDebugger)

const debugMessageNumber = debuggerData
? Object.keys(debuggerData).length
: undefined
const debugMessageNumber = useMemo(() => {
if (debuggerData) {
let count = 0
Object.keys(debuggerData).forEach((errors) => {
if (Array.isArray(debuggerData[errors])) {
count += debuggerData[errors].length
}
})
return count
}
return undefined
}, [debuggerData])
const dispatch = useDispatch()

const handleClickDebuggerIcon = () => {
Expand Down
6 changes: 4 additions & 2 deletions apps/builder/src/page/App/components/Debugger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export const Debugger: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
<div css={errorContentStyle}>
{Object.keys(debuggerData)?.map((name, index) => {
const error = debuggerData[name]
if (isArray(error)) {

if (isArray(error) && error.length > 0) {
return error?.map((item) => {
return <ErrorItem key={index} pathName={name} item={item} />
})
} else {
return null
}
return <ErrorItem key={name} pathName={name} item={error} />
})}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ export const ResizingAndDragContainer: FC<ResizingAndDragContainerProps> = (
return (
keys.length > 0 &&
keys.some((key) => {
return key.startsWith(displayName)
return (
Array.isArray(errors[key]) &&
errors[key].length > 0 &&
key.startsWith(displayName)
)
})
)
}, [displayName, errors])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ const WrapperContainer: FC<WrapperContainerProps> = (props) => {
return (
keys.length > 0 &&
keys.some((key) => {
return key.startsWith(displayName)
return (
Array.isArray(errors[key]) &&
errors[key].length > 0 &&
key.startsWith(displayName)
)
})
)
}, [displayName, errors])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export const useScaleStateSelector = (displayName: string) => {
return (
keys.length > 0 &&
keys.some((key) => {
return key.startsWith(displayName)
return (
Array.isArray(errors[key]) &&
errors[key].length > 0 &&
key.startsWith(displayName)
)
})
)
}, [displayName, errors])
Expand Down
20 changes: 11 additions & 9 deletions apps/builder/src/utils/executionTreeHelper/executionTreeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import i18n from "@/i18n/config"
import { getContainerListDisplayNameMappedChildrenNodeDisplayName } from "@/redux/currentApp/components/componentsSelector"
import {
DependenciesState,
ErrorShape,
ExecutionErrorType,
ExecutionState,
} from "@/redux/currentApp/executionTree/executionState"
Expand Down Expand Up @@ -124,7 +123,7 @@ export class ExecutionTreeFactory {
}

validateTree(tree: RawTreeShape) {
const validateErrors: Record<string, any> = klona(this.errorTree)
const validateErrors: Record<string, any> = {}
const validateResultTree = Object.keys(tree).reduce(
(current: RawTreeShape, displayName) => {
const widgetOrAction = current[displayName]
Expand Down Expand Up @@ -555,7 +554,9 @@ export class ExecutionTreeFactory {
)
const { validateErrors, validateResultTree } =
this.validateTree(evaluatedTree)

const mergedError = merge({}, validateErrors, errorTree)

const errorTreeResult = this.mergeErrorTree(
mergedError,
mergedUpdatePathMapAction,
Expand Down Expand Up @@ -717,14 +718,15 @@ export class ExecutionTreeFactory {
set(current, fullPath, evaluateValue)
}
} catch (e) {
const oldError = errorTree[fullPath] ?? ([] as ErrorShape[])
if (Array.isArray(oldError)) {
oldError.push({
errorType: ExecutionErrorType.EVALUATED,
errorMessage: (e as Error).message,
errorName: (e as Error).name,
})
let oldError = errorTree[fullPath]
if (!Array.isArray(oldError)) {
oldError = []
}
oldError.push({
errorType: ExecutionErrorType.EVALUATED,
errorMessage: (e as Error).message,
errorName: (e as Error).name,
})
errorTree[fullPath] = oldError
set(current, fullPath, undefined)
}
Expand Down
Loading