From 808138de633e410c1d3867d4fb7cb74967647605 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Tue, 30 Jul 2024 16:54:10 +0100 Subject: chore: remove ui directory (#2329) This is still in development, but rather than clutter the commit history and issues with an unreleased project I've split the UI into its own repo. Once ready for release, I'll either merge the ui code back in, or just make the repo public. --- ui/src/pages/Dotfiles.tsx | 109 ----------------- ui/src/pages/History.tsx | 73 ------------ ui/src/pages/Home.tsx | 295 ---------------------------------------------- ui/src/pages/Runbooks.tsx | 25 ---- 4 files changed, 502 deletions(-) delete mode 100644 ui/src/pages/Dotfiles.tsx delete mode 100644 ui/src/pages/History.tsx delete mode 100644 ui/src/pages/Home.tsx delete mode 100644 ui/src/pages/Runbooks.tsx (limited to 'ui/src/pages') diff --git a/ui/src/pages/Dotfiles.tsx b/ui/src/pages/Dotfiles.tsx deleted file mode 100644 index 85f5b0e0..00000000 --- a/ui/src/pages/Dotfiles.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import { useState } from "react"; -import Aliases from "@/components/dotfiles/Aliases"; -import Vars from "@/components/dotfiles/Vars"; - -enum Section { - Aliases, - Vars, - Snippets, -} - -function renderDotfiles(current: Section) { - switch (current) { - case Section.Aliases: - return ; - case Section.Vars: - return ; - case Section.Snippets: - return
; - } -} - -interface HeaderProps { - current: Section; - setCurrent: (section: Section) => void; -} - -interface TabsProps { - current: Section; - setCurrent: (section: Section) => void; -} - -function Header({ current, setCurrent }: HeaderProps) { - return ( -
-
-

- Dotfiles -

-
- - -
- ); -} - -function classNames(...classes: any[]) { - return classes.filter(Boolean).join(" "); -} - -function Tabs({ current, setCurrent }: TabsProps) { - let tabs = [ - { - name: "Aliases", - isCurrent: () => current === Section.Aliases, - section: Section.Aliases, - }, - { - name: "Vars", - isCurrent: () => current === Section.Vars, - section: Section.Vars, - }, - { - name: "Snippets", - isCurrent: () => current === Section.Snippets, - section: Section.Snippets, - }, - ]; - - return ( -
-
- -
-
- ); -} - -export default function Dotfiles() { - let [current, setCurrent] = useState(Section.Aliases); - console.log(current); - - return ( -
-
-
- Manage your shell aliases, variables and paths - {renderDotfiles(current)} -
-
- ); -} diff --git a/ui/src/pages/History.tsx b/ui/src/pages/History.tsx deleted file mode 100644 index 32f5217e..00000000 --- a/ui/src/pages/History.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { useEffect, useState, useRef } from "react"; -import { useVirtualizer } from "@tanstack/react-virtual"; - -import HistoryList from "@/components/HistoryList.tsx"; -import HistorySearch from "@/components/HistorySearch.tsx"; - -import { AtuinState, useStore } from "@/state/store"; - -export default function Search() { - const history = useStore((state: AtuinState) => state.shellHistory); - const refreshHistory = useStore( - (state: AtuinState) => state.refreshShellHistory, - ); - const historyNextPage = useStore( - (state: AtuinState) => state.historyNextPage, - ); - - let [query, setQuery] = useState(""); - - useEffect(() => { - (async () => { - // nothing rn - })(); - - refreshHistory(); - }, []); - - const parentRef = useRef(null); - - const rowVirtualizer = useVirtualizer({ - count: history.length, - getScrollElement: () => parentRef.current, - estimateSize: () => 90, - overscan: 5, - }); - - useEffect(() => { - const [lastItem] = rowVirtualizer.getVirtualItems().slice(-1); - - if (!lastItem) return; // no undefined plz - if (lastItem.index < history.length - 1) return; // if we're not at the end yet, bail - - // we're at the end! more rows plz! - historyNextPage(query); - }, [rowVirtualizer.getVirtualItems()]); - - return ( - <> -
-
- { - setQuery(q); - refreshHistory(q); - }} - refresh={() => { - refreshHistory(query); - }} - /> -
- -
- -
-
- - ); -} diff --git a/ui/src/pages/Home.tsx b/ui/src/pages/Home.tsx deleted file mode 100644 index 2e93a893..00000000 --- a/ui/src/pages/Home.tsx +++ /dev/null @@ -1,295 +0,0 @@ -import React, { useEffect } from "react"; -import { formatRelative } from "date-fns"; -import { Tooltip as ReactTooltip } from "react-tooltip"; - -import { AtuinState, useStore } from "@/state/store"; -import { useToast } from "@/components/ui/use-toast"; -import { ToastAction } from "@/components/ui/toast"; -import { invoke } from "@tauri-apps/api/core"; -import { - Card, - CardHeader, - CardBody, - Listbox, - ListboxItem, -} from "@nextui-org/react"; - -import { - Bar, - BarChart, - CartesianGrid, - LabelList, - XAxis, - YAxis, -} from "recharts"; -import { ChartConfig, ChartContainer } from "@/components/ui/chart"; - -import { Clock, Terminal } from "lucide-react"; - -import ActivityCalendar from "react-activity-calendar"; -import HistoryRow from "@/components/history/HistoryRow"; -import { ShellHistory } from "@/state/models"; - -function StatCard({ name, stat }: any) { - return ( - - -

{name}

-
- -

{stat}

-
-
- ); -} - -function TopChart({ chartData }: any) { - const chartConfig = { - command: { - label: "Command", - color: "#c4edde", - }, - } satisfies ChartConfig; - - return ( - - - - value.slice(0, 3)} - hide - /> - - - - - - - - ); -} - -function Header({ name }: any) { - let greeting = name && name.length > 0 ? "Hey, " + name + "!" : "Hey!"; - - return ( -
-
-

- {greeting} -

-

- Welcome to{" "} - - Atuin - - . -

-
-
- ); -} - -const explicitTheme = { - light: ["#f0f0f0", "#c4edde", "#7ac7c4", "#f73859", "#384259"], - dark: ["#f0f0f0", "#c4edde", "#7ac7c4", "#f73859", "#384259"], -}; - -export default function Home() { - const homeInfo = useStore((state: AtuinState) => state.homeInfo); - const user = useStore((state: AtuinState) => state.user); - const calendar = useStore((state: AtuinState) => state.calendar); - const runbooks = useStore((state: AtuinState) => state.runbooks); - const weekStart = useStore((state: AtuinState) => state.weekStart); - - const refreshHomeInfo = useStore( - (state: AtuinState) => state.refreshHomeInfo, - ); - const refreshUser = useStore((state: AtuinState) => state.refreshUser); - const refreshCalendar = useStore( - (state: AtuinState) => state.refreshCalendar, - ); - const refreshRunbooks = useStore( - (state: AtuinState) => state.refreshRunbooks, - ); - - const { toast } = useToast(); - - useEffect(() => { - refreshHomeInfo(); - refreshUser(); - refreshCalendar(); - refreshRunbooks(); - - console.log(homeInfo); - - let setup = async () => { - let installed = await invoke("is_cli_installed"); - console.log("CLI installation status:", installed); - - if (!installed) { - toast({ - title: "Atuin CLI", - description: "CLI not detected - install?", - action: ( - { - let install = async () => { - toast({ - title: "Atuin CLI", - description: "Install in progress...", - }); - - console.log("Installing CLI..."); - await invoke("install_cli"); - - console.log("Setting up plugin..."); - await invoke("setup_cli"); - - toast({ - title: "Atuin CLI", - description: "Installation complete", - }); - }; - install(); - }} - > - Install - - ), - }); - } - }; - - setup(); - }, []); - - if (!homeInfo) { - return
Loading...
; - } - - return ( -
-
-
-
-
- - - - - - - -

Activity graph

-
- - - React.cloneElement(block, { - "data-tooltip-id": "react-tooltip", - "data-tooltip-html": `${activity.count} commands on ${activity.date}`, - }) - } - /> - - -
- - - -

Quick actions

-
- - - - } - > - New runbook - - } - > - Shell History - - - -
- - - -

Recent commands

-
- - {homeInfo.recentCommands?.map((i: ShellHistory) => { - return ; - })} - -
- - - -

Top commands

-
- - - -
-
-
- ); -} diff --git a/ui/src/pages/Runbooks.tsx b/ui/src/pages/Runbooks.tsx deleted file mode 100644 index a0b844a6..00000000 --- a/ui/src/pages/Runbooks.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import Editor from "@/components/runbooks/editor/Editor"; -import List from "@/components/runbooks/List"; - -import { useStore } from "@/state/store"; - -export default function Runbooks() { - const currentRunbook = useStore((store) => store.currentRunbook); - - return ( -
- - {currentRunbook && ( -
- -
- )} - - {!currentRunbook && ( -
-

Select or create a runbook

-
- )} -
- ); -} -- cgit v1.3.1