Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
owenlongbo committed Oct 3, 2022
2 parents e70b876 + 49146fa commit c34fe51
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"author": "illa Family",
"license": "Apache-2.0",
"version": "0.0.0",
"version": "1.1.1",
"scripts": {
"dev": "vite --mode cloud",
"build-cloud": "vite build --mode cloud",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export const ActionTitleBar: FC<ActionTitleBarProps> = (props) => {
}
}

const renderButton =
runMode === "run" ? action.actionType !== "transformer" : true

useEffect(() => {
// Clear the previous result when changing the selected action
onActionRun(undefined)
Expand Down Expand Up @@ -90,7 +93,7 @@ export const ActionTitleBar: FC<ActionTitleBarProps> = (props) => {
>
<Button colorScheme="grayBlue" leftIcon={<MoreIcon size="14px" />} />
</Dropdown>
{action.actionType !== "transformer" && (
{renderButton && (
<Button
ml="8px"
colorScheme="techPurple"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC } from "react"
import { useDispatch, useSelector } from "react-redux"
import { getSelectedAction } from "@/redux/config/configSelector"
import { FC, useMemo } from "react"
import { useDispatch } from "react-redux"
import { configActions } from "@/redux/config/configSlice"
import { CodeEditor } from "@/components/CodeEditor"
import { TransformerAction } from "@/redux/currentApp/action/transformerAction"
Expand All @@ -17,13 +16,18 @@ export const TransformerPanel: FC<TransformerPanelProps> = props => {
const action = props.action
const dispatch = useDispatch()
const { t } = useTranslation()
const finalValue = useMemo(() => {
return (
action?.content?.transformerString ||
"// Tip: assign your external references to variables instead of chaining off the curly brackets.\n" +
"return 5"
)
}, [action?.content?.transformerString])

return (
<div css={transformerPanelContainerStyle}>
<CodeEditor
value={
"// Tip: assign your external references to variables instead of chaining off the curly brackets.\n" +
"return 5"
}
value={finalValue}
css={transformerEditorStyle}
lineNumbers
height="88px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getDisplayNameAndAttrPath,
getWidgetOrActionDynamicAttrPaths,
isDynamicString,
wrapFunctionCode,
} from "@/utils/evaluateDynamicString/utils"
import { getSnippets } from "@/utils/evaluateDynamicString/dynamicConverter"
import toposort from "toposort"
Expand Down Expand Up @@ -392,7 +393,23 @@ export class ExecutionTreeFactory {
return current
}
}
if (widgetOrAction.triggerMode === "automate") {
if (widgetOrAction.actionType === "transformer") {
const evaluateTransform = wrapFunctionCode(
widgetOrAction.content.transformerString,
)
const canEvalString = `{{${evaluateTransform}()}}`
let calcResult = ""
try {
calcResult = evaluateDynamicString("", canEvalString, current)
set(current, `${widgetOrAction.displayName}.value`, calcResult)
} catch (e) {
console.log(e)
}
}
if (
widgetOrAction.actionType !== "transformer" &&
widgetOrAction.triggerMode === "automate"
) {
const {
$actionId,
$resourceId,
Expand Down
2 changes: 1 addition & 1 deletion illa-design

0 comments on commit c34fe51

Please sign in to comment.