Skip to content

Commit

Permalink
feat(frontend): fix up action executed in raw execute
Browse files Browse the repository at this point in the history
  • Loading branch information
hkdeman committed Sep 2, 2024
1 parent d11df08 commit 24c9a24
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions frontend/src/pages/raw-execute/raw-execute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from "classnames";
import { indexOf } from "lodash";
import { FC, useCallback, useState } from "react";
import { FC, useCallback, useMemo, useState } from "react";
import { v4 } from "uuid";
import { AnimatedButton } from "../../components/button";
import { CodeEditor } from "../../components/editor";
Expand Down Expand Up @@ -39,6 +39,11 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
onDelete?.(cellId);
}, [cellId, onDelete]);


const codeWithoutComments = useMemo(() => {
return code.split("\n").filter(text => !text.startsWith("--")).join("\n");
}, [code]);

return <div className="flex flex-col grow group/cell">
<div className="relative">
<div className="flex grow h-[150px] border border-gray-200 rounded-md overflow-hidden dark:bg-white/10 dark:border-white/5">
Expand Down Expand Up @@ -68,11 +73,17 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
</div>
}
{
rows != null &&
<div className="flex flex-col w-full h-[250px] mt-4">
<Table columns={rows.RawExecute.Columns.map(c => c.Name)} columnTags={rows.RawExecute.Columns.map(c => c.Type)}
rows={rows.RawExecute.Rows} totalPages={1} currentPage={1} disableEdit={true} />
</div>
rows != null &&
(codeWithoutComments.trim().startsWith("SELECT")
?
<div className="flex flex-col w-full h-[250px] mt-4">
<Table columns={rows.RawExecute.Columns.map(c => c.Name)} columnTags={rows.RawExecute.Columns.map(c => c.Type)}
rows={rows.RawExecute.Rows} totalPages={1} currentPage={1} disableEdit={true} />
</div>
: <div className="bg-white/10 text-neutral-800 dark:text-neutral-300 rounded-lg p-2 flex gap-2 self-start items-center my-4">
Action Executed
{Icons.CheckCircle}
</div>)
}
</div>
}
Expand Down

0 comments on commit 24c9a24

Please sign in to comment.