From 1e8461947287f7b41975e0b1ad8fdcd09b50cb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Lu=C3=ADs?= Date: Mon, 29 Jan 2024 19:43:55 -0300 Subject: [PATCH] feat: selected path display in nautilus --- src/components/nautilus.tsx | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/components/nautilus.tsx b/src/components/nautilus.tsx index 69dfd94..e8a03ca 100644 --- a/src/components/nautilus.tsx +++ b/src/components/nautilus.tsx @@ -27,7 +27,7 @@ import { api } from '~/utils/api'; import { Button } from './ui/button'; import { Dialog, DialogContent, DialogTrigger } from './ui/dialog'; import { Input } from './ui/input'; -import { ScrollArea } from './ui/scroll-area'; +import { ScrollArea, ScrollBar } from './ui/scroll-area'; type Shortcut = { name: string; @@ -134,8 +134,12 @@ const Nautilus = ({ onSelect }: { onSelect: (p: string) => void }) => { setPath(data.path); } + function formatPath(p: string) { + return p.endsWith('/') ? p.slice(0, -1) : p; + } function handleSelect() { - const p = `${path}/${selected}`; + let p = formatPath(path); + p = `${p}/${selected}`; onSelect(p); toast.success(`Selected ${p}`); } @@ -145,6 +149,26 @@ const Nautilus = ({ onSelect }: { onSelect: (p: string) => void }) => { return (
+
+ +

+ + selected:{' '} + + {`${formatPath(path)}/${selected}`} +

+ +
+ +
))} - | -
void form.handleSubmit(onSubmit)(...args)}>