Skip to content

Commit 462572b

Browse files
authored
Merge pull request #126 from FlowTestAI/update-canvas-store
fix: update canvas store correctly to render react flow with latest changes
2 parents 646f7e6 + d98c5fb commit 462572b

7 files changed

Lines changed: 213 additions & 115 deletions

File tree

packages/flowtest-cli/graph/Graph.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,21 @@ class Graph {
206206
}
207207
} catch (err) {
208208
console.log(chalk.red(`Flow failed at: ${JSON.stringify(node.data)} due to ${err}`));
209-
this.logger.add(LogLevel.ERROR, `Flow failed due to ${err}`, node);
209+
this.logger.add(LogLevel.ERROR, `Flow failed due to ${err}`, {
210+
type: 'errorNode',
211+
data: node.data,
212+
});
210213
return {
211214
status: 'Failed',
212215
};
213216
}
214217

215218
if (result === undefined) {
216219
console.log(chalk.red(`Flow failed due to failure to evaluate result at node: ${node.data}`));
217-
this.logger.add(LogLevel.ERROR, 'Flow failed due to failure to evaluate result', node);
220+
this.logger.add(LogLevel.ERROR, 'Flow failed due to failure to evaluate result', {
221+
type: 'errorNode',
222+
data: node.data,
223+
});
218224
return {
219225
status: 'Failed',
220226
};

src/components/atoms/Editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const hideScrollbar = EditorView.theme({
4646
export const Editor = ({ ...props }) => {
4747
const editor = useRef();
4848
const [view, setView] = useState(null);
49-
const [dynamicOptions, setDynamicOptions] = useState([]);
49+
const [dynamicOptions, setDynamicOptions] = useState(props.completionOptions || []);
5050

5151
if (view) {
5252
if (!isEqual(dynamicOptions, props.completionOptions)) {

src/components/atoms/common/TextEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const highlightStyle = EditorView.baseTheme({
100100
export const TextEditor = ({ placeHolder, onChangeHandler, value, disableState, completionOptions, styles }) => {
101101
const editor1 = useRef();
102102
const [view, setView] = useState(null);
103-
const [dynamicOptions, setDynamicOptions] = useState([]);
103+
const [dynamicOptions, setDynamicOptions] = useState(completionOptions);
104104

105105
if (view) {
106106
if (!isEqual(dynamicOptions, completionOptions)) {

src/components/molecules/flow/graph/Graph.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,20 @@ class Graph {
183183
throw Error(`Timeout of ${this.timeout} ms exceeded, stopping graph run`);
184184
}
185185
} catch (err) {
186-
this.logger.add(LogLevel.ERROR, `Flow failed due to ${err}`, node);
186+
this.logger.add(LogLevel.ERROR, `Flow failed due to ${err}`, {
187+
type: 'errorNode',
188+
data: node.data,
189+
});
187190
return {
188191
status: 'Failed',
189192
};
190193
}
191194

192195
if (result === undefined) {
193-
this.logger.add(LogLevel.ERROR, 'Flow failed due to failure to evaluate result', node);
196+
this.logger.add(LogLevel.ERROR, 'Flow failed due to failure to evaluate result', {
197+
type: 'errorNode',
198+
data: node.data,
199+
});
194200
return {
195201
status: 'Failed',
196202
};

src/components/molecules/flow/graph/compute/requestnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class requestNode extends Node {
3232

3333
const res = await this.runHttpRequest(options);
3434

35-
if (this.nodeData.requestBody.type === 'form-data') {
35+
if (this.nodeData?.requestBody?.type === 'form-data') {
3636
options.data.value = '<BASE64_ENCODED_FILE_DATA>';
3737
}
3838

@@ -111,7 +111,7 @@ class requestNode extends Node {
111111
data: requestData,
112112
};
113113

114-
if (this.auth && this.auth.type === 'basic-auth') {
114+
if (this.auth && this.auth?.type === 'basic-auth') {
115115
options.auth = {};
116116
options.auth.username = this.auth.username;
117117
options.auth.password = this.auth.password;

src/components/molecules/flow/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ export const initFlowData = {
119119
id: '1',
120120
type: 'authNode',
121121
description: 'Define authentication for the requests',
122-
data: {},
122+
data: {
123+
type: 'no-auth',
124+
},
123125
position: {
124126
x: 400,
125127
y: 150,

0 commit comments

Comments
 (0)