From ceabf1fca552d3a823c789bb3b5795590dcd9825 Mon Sep 17 00:00:00 2001 From: P PUNITH KRISHNA <32421081+punith300i@users.noreply.github.com> Date: Mon, 30 Oct 2023 19:02:01 -0700 Subject: [PATCH] updated PR reviews, removed redundant variables --- .../transformation/TransformationResult.ts | 4 +- .../pages/table/forms/TransformationForm.tsx | 440 +++++++++--------- 2 files changed, 217 insertions(+), 227 deletions(-) diff --git a/www/src/models/transformation/TransformationResult.ts b/www/src/models/transformation/TransformationResult.ts index c28c737..1d86048 100644 --- a/www/src/models/transformation/TransformationResult.ts +++ b/www/src/models/transformation/TransformationResult.ts @@ -1,6 +1,4 @@ -import { Record } from "gena-app"; - -export interface TransformationResult extends Record { +export interface TransformationResult { path: number; value: string; ok: string; diff --git a/www/src/pages/table/forms/TransformationForm.tsx b/www/src/pages/table/forms/TransformationForm.tsx index 161aaeb..8fd70e6 100644 --- a/www/src/pages/table/forms/TransformationForm.tsx +++ b/www/src/pages/table/forms/TransformationForm.tsx @@ -1,4 +1,4 @@ -import { WithStyles, withStyles } from "@material-ui/styles"; +import { WithStyles } from "@material-ui/styles"; import { Button, Radio, @@ -29,213 +29,226 @@ export interface TransformationFormProps { table: TableModel; } -export const TransformationForm = withStyles(styles)( - observer( - ({ - classes, - table, - }: TransformationFormProps & WithStyles) => { - const onDone = () => Modal.destroyAll(); - const actionRef = useRef(); - const [form] = Form.useForm(); - const { transformationStore } = useStores(); - const [result, setResult] = useState< - TransformationResult[] | undefined - >(); +const editorOptions = { + autoIndent: "full", + contextmenu: true, + fontFamily: "monospace", + fontSize: 13, + lineHeight: 24, + matchBrackets: "always", + minimap: { + enabled: false, + }, + scrollbar: { + horizontalSliderSize: 4, + verticalSliderSize: 18, + }, + selectOnLineNumbers: true, + roundedSelection: false, + readOnly: false, + cursorStyle: "line", + automaticLayout: true, +}; - const columns = [ - { dataIndex: "row_id", title: "Row ID" }, - { dataIndex: "previous_value", title: "Previous Value" }, - { - dataIndex: "result", - title: "Result", - render: (transformed_value: string | boolean) => { - if ( - typeof transformed_value === "string" && - transformed_value.includes("Traceback") - ) { - return ( - <> - { - -
{transformed_value}
-
- } - - ); - } else { - return transformed_value; - } - }, - }, - ]; +export const TransformationForm = observer( + ({ table }: TransformationFormProps) => { + const onDone = () => Modal.destroyAll(); + const actionRef = useRef(); + const [form] = Form.useForm(); + const { transformationStore } = useStores(); + const [result, setResult] = useState(); - const onExecute = async () => { - const transformationPayload: Transformation = { - id: -1, - tableId: table.id, - type: form.getFieldValue("type"), - code: form.getFieldValue("code"), - mode: "restrictedpython", - datapath: form.getFieldValue("datapath"), - outputpath: form.getFieldValue("outputpath"), - tolerance: form.getFieldValue("tolerance"), - rows: form.getFieldValue("rows"), - }; + const columns = [ + { dataIndex: "row_id", title: "Row ID" }, + { dataIndex: "previous_value", title: "Previous Value" }, + { + dataIndex: "result", + title: "Result", + render: (transformed_value: string | boolean) => { + if ( + typeof transformed_value === "string" && + transformed_value.includes("Traceback") + ) { + return ( + <> + { + +
{transformed_value}
+
+ } + + ); + } else { + return transformed_value; + } + }, + }, + ]; - let response = await transformationStore.testTransformation( - transformationPayload - ); - setResult(response); + const onExecute = async () => { + const transformationPayload: Transformation = { + id: -1, + tableId: table.id, + type: form.getFieldValue("type"), + code: form.getFieldValue("code"), + mode: "restrictedpython", + datapath: form.getFieldValue("datapath"), + outputpath: form.getFieldValue("outputpath"), + tolerance: form.getFieldValue("tolerance"), + rows: form.getFieldValue("rows"), }; - return ( -
- - - - - - - - - ({ - label: column, - value: column, - }))} - placeholder="Please select columns" - /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set To Blank - Store Error - Keep Original - Abort - - - - - - - - - - - - - - - - - - {Array.isArray(result) ? ( - - ) : result != undefined ? ( - -
{result}
-
- ) : ( - <> - )} - - - + let response = await transformationStore.testTransformation( + transformationPayload ); - } - ) + setResult(response); + }; + + return ( + + + + + + + + + + ({ + label: column, + value: column, + }))} + placeholder="Please select columns" + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Set To Blank + Store Error + Keep Original + Abort + + + + + + + + + + + + + + + + + + {Array.isArray(result) ? ( +
+ ) : result != undefined ? ( + +
{result}
+
+ ) : ( + <> + )} + + + + ); + } ); export const CustomEditor = ({ @@ -245,34 +258,13 @@ export const CustomEditor = ({ value?: string; onChange?: (value: string | undefined) => void; }) => { - const options = { - autoIndent: "full", - contextmenu: true, - fontFamily: "monospace", - fontSize: 13, - lineHeight: 24, - matchBrackets: "always", - minimap: { - enabled: false, - }, - scrollbar: { - horizontalSliderSize: 4, - verticalSliderSize: 18, - }, - selectOnLineNumbers: true, - roundedSelection: false, - readOnly: false, - cursorStyle: "line", - automaticLayout: true, - }; - return (