From 34265613b80d1d2249d276da5fcd5e4c274af357 Mon Sep 17 00:00:00 2001
From: Ellie Huxtable <ellie@elliehuxtable.com>
Date: Tue, 14 May 2024 12:16:04 +0700
Subject: feat(ui): add history explore (#2022)

* break out HistoryRow, add drawer

* syntax highlighting!

* smaller text

* allow inspecting all old commands, no drag command

* fix query bug

* add loader
---
 ui/src/components/history/HistoryInspect.tsx | 40 ++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 ui/src/components/history/HistoryInspect.tsx

(limited to 'ui/src/components/history/HistoryInspect.tsx')

diff --git a/ui/src/components/history/HistoryInspect.tsx b/ui/src/components/history/HistoryInspect.tsx
new file mode 100644
index 00000000..8e820169
--- /dev/null
+++ b/ui/src/components/history/HistoryInspect.tsx
@@ -0,0 +1,40 @@
+import { useState, useEffect } from "react";
+
+import PacmanLoader from "react-spinners/PacmanLoader";
+
+import CodeBlock from "@/components/CodeBlock";
+import HistoryRow from "@/components/history/HistoryRow";
+import { inspectCommandHistory } from "@/state/models";
+
+function renderLoading() {
+  return (
+    <div className="flex items-center justify-center h-full">
+      <PacmanLoader color="#26bd65" />
+    </div>
+  );
+}
+
+export default function HistoryInspect({ history }: any) {
+  let [other, setOther] = useState([]);
+
+  useEffect(() => {
+    (async () => {
+      let inspect = await inspectCommandHistory(history);
+      setOther(inspect.other);
+    })();
+  }, []);
+
+  if (other.length == 0) return renderLoading();
+
+  return (
+    <div className="overflow-y-auto">
+      <CodeBlock code={history.command} language="bash" />
+
+      <div>
+        {other.map((i: any) => {
+          return <HistoryRow h={i} />;
+        })}
+      </div>
+    </div>
+  );
+}
-- 
cgit v1.3.1

