From 6cd4319fcf540ef70f74cc2f10d0d4297ee7b788 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Thu, 11 Apr 2024 16:59:01 +0100 Subject: feat(gui): add base structure (#1935) * initial * ui things * cargo * update, add history refresh button * history page a bit better, add initial dotfiles page * re-org layout * bye squigglies * add dotfiles ui, show aliases * add default shell detection * put stats in a little drawer, alias import changes * use new table for aliases, add alias deleting * support adding aliases * close drawer when added, no alias autocomplete * clippy, format * attempt to ensure gdk is installed ok * sudo * no linux things on mac ffs * I forgot we build for windows too... end of day * remove tauri backend from workspace --- ui/src/pages/Dotfiles.tsx | 32 ++++++++++++++ ui/src/pages/History.tsx | 108 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 ui/src/pages/Dotfiles.tsx create mode 100644 ui/src/pages/History.tsx (limited to 'ui/src/pages') diff --git a/ui/src/pages/Dotfiles.tsx b/ui/src/pages/Dotfiles.tsx new file mode 100644 index 00000000..bd209062 --- /dev/null +++ b/ui/src/pages/Dotfiles.tsx @@ -0,0 +1,32 @@ +import { useState } from "react"; + +import { Cog6ToothIcon } from "@heroicons/react/24/outline"; + +import Aliases from "@/components/dotfiles/Aliases"; + +import { Drawer } from "@/components/drawer"; +import { invoke } from "@tauri-apps/api/core"; + +function Header() { + return ( +
+
+

+ Dotfiles +

+
+
+ ); +} + +export default function Dotfiles() { + return ( +
+
+
+ Manage your shell aliases, variables and paths + +
+
+ ); +} diff --git a/ui/src/pages/History.tsx b/ui/src/pages/History.tsx new file mode 100644 index 00000000..f74c16ac --- /dev/null +++ b/ui/src/pages/History.tsx @@ -0,0 +1,108 @@ +import { Fragment, useState, useEffect } from "react"; +import { Dialog, Transition } from "@headlessui/react"; +import { + Bars3Icon, + ChartPieIcon, + Cog6ToothIcon, + HomeIcon, + XMarkIcon, +} from "@heroicons/react/24/outline"; + +import Logo from "../assets/logo-light.svg"; + +import { invoke } from "@tauri-apps/api/core"; + +import HistoryList from "@/components/HistoryList.tsx"; +import HistorySearch from "@/components/HistorySearch.tsx"; +import Stats from "@/components/history/Stats.tsx"; +import Drawer from "@/components/Drawer.tsx"; + +function refreshHistory( + setHistory: React.Dispatch>, + query: String | null, +) { + if (query) { + invoke("search", { query: query }) + .then((res: any[]) => { + setHistory(res); + }) + .catch((e) => { + console.log(e); + }); + } else { + invoke("list").then((h: any[]) => { + setHistory(h); + }); + } +} + +function Header() { + return ( +
+
+

+ Shell History +

+
+
+ + + + + + } + > + + +
+
+ ); +} + +export default function Search() { + let [history, setHistory] = useState([]); + + useEffect(() => { + refreshHistory(setHistory, null); + }, []); + + return ( + <> +
+
+
+

A history of all the commands you run in your shell.

+
+ +
+ { + refreshHistory(setHistory, query); + }} + /> +
+ +
+ +
+
+ + ); +} -- cgit v1.3.1