|
@@ -8,9 +8,10 @@ import { FC, useContext, useEffect, useState } from 'react';
|
|
|
import classnames from 'classnames';
|
|
import classnames from 'classnames';
|
|
|
import { WorkflowInputs, WorkflowOutputs } from '@flowgram.ai/runtime-interface';
|
|
import { WorkflowInputs, WorkflowOutputs } from '@flowgram.ai/runtime-interface';
|
|
|
import { useService } from '@flowgram.ai/free-layout-editor';
|
|
import { useService } from '@flowgram.ai/free-layout-editor';
|
|
|
-import { Button, SideSheet } from '@douyinfe/semi-ui';
|
|
|
|
|
|
|
+import { Button, SideSheet, Switch } from '@douyinfe/semi-ui';
|
|
|
import { IconClose, IconPlay, IconSpin } from '@douyinfe/semi-icons';
|
|
import { IconClose, IconPlay, IconSpin } from '@douyinfe/semi-icons';
|
|
|
|
|
|
|
|
|
|
+import { TestRunJsonInput } from '../testrun-json-input';
|
|
|
import { TestRunForm } from '../testrun-form';
|
|
import { TestRunForm } from '../testrun-form';
|
|
|
import { NodeStatusGroup } from '../node-status-bar/group';
|
|
import { NodeStatusGroup } from '../node-status-bar/group';
|
|
|
import { WorkflowRuntimeService } from '../../../plugins/runtime-plugin/runtime-service';
|
|
import { WorkflowRuntimeService } from '../../../plugins/runtime-plugin/runtime-service';
|
|
@@ -39,6 +40,17 @@ export const TestRunSidePanel: FC<TestRunSidePanelProps> = ({ visible, onCancel
|
|
|
| undefined
|
|
| undefined
|
|
|
>();
|
|
>();
|
|
|
|
|
|
|
|
|
|
+ // en - Use localStorage to persist the JSON mode state
|
|
|
|
|
+ const [inputJSONMode, _setInputJSONMode] = useState(() => {
|
|
|
|
|
+ const savedMode = localStorage.getItem('testrun-input-json-mode');
|
|
|
|
|
+ return savedMode ? JSON.parse(savedMode) : false;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const setInputJSONMode = (checked: boolean) => {
|
|
|
|
|
+ _setInputJSONMode(checked);
|
|
|
|
|
+ localStorage.setItem('testrun-input-json-mode', JSON.stringify(checked));
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const onTestRun = async () => {
|
|
const onTestRun = async () => {
|
|
|
if (isRunning) {
|
|
if (isRunning) {
|
|
|
await runtimeService.taskCancel();
|
|
await runtimeService.taskCancel();
|
|
@@ -90,8 +102,20 @@ export const TestRunSidePanel: FC<TestRunSidePanelProps> = ({ visible, onCancel
|
|
|
|
|
|
|
|
const renderForm = (
|
|
const renderForm = (
|
|
|
<div className={styles['testrun-panel-form']}>
|
|
<div className={styles['testrun-panel-form']}>
|
|
|
- <div className={styles.title}>Input Form</div>
|
|
|
|
|
- <TestRunForm values={values} setValues={setValues} />
|
|
|
|
|
|
|
+ <div className={styles['testrun-panel-input']}>
|
|
|
|
|
+ <div className={styles.title}>Input Form</div>
|
|
|
|
|
+ <div>JSON Mode</div>
|
|
|
|
|
+ <Switch
|
|
|
|
|
+ checked={inputJSONMode}
|
|
|
|
|
+ onChange={(checked: boolean) => setInputJSONMode(checked)}
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {inputJSONMode ? (
|
|
|
|
|
+ <TestRunJsonInput values={values} setValues={setValues} />
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <TestRunForm values={values} setValues={setValues} />
|
|
|
|
|
+ )}
|
|
|
{errors?.map((e) => (
|
|
{errors?.map((e) => (
|
|
|
<div className={styles.error} key={e}>
|
|
<div className={styles.error} key={e}>
|
|
|
{e}
|
|
{e}
|