Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wwayne committed Jun 7, 2024
1 parent f106ac8 commit dfb4495
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 135 deletions.
37 changes: 37 additions & 0 deletions ee/tabby-ui/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use client'

import { useState } from 'react'
import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import logoUrl from '@/assets/tabby.png'
import { noop } from 'lodash-es'

import { SESSION_STORAGE_KEY } from '@/lib/constants'
import { useEnableSearch } from '@/lib/experiment-flags'
import { graphql } from '@/lib/gql/generates'
import { useHealth } from '@/lib/hooks/use-health'
import { useMe } from '@/lib/hooks/use-me'
Expand All @@ -14,6 +18,7 @@ import { useSignOut } from '@/lib/tabby/auth'
import { useMutation } from '@/lib/tabby/gql'
import { Button } from '@/components/ui/button'
import { CardContent, CardFooter } from '@/components/ui/card'
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog'
import {
IconChat,
IconCode,
Expand All @@ -22,6 +27,7 @@ import {
IconLogout,
IconMail,
IconRotate,
IconSearch,
IconSpinner,
IconUser,
IconVSCode
Expand All @@ -36,6 +42,7 @@ import {
} from '@/components/ui/tooltip'
import { CopyButton } from '@/components/copy-button'
import SlackDialog from '@/components/slack-dialog'
import TextAreaSearch from '@/components/textarea-search'
import { ThemeToggle } from '@/components/theme-toggle'
import { UserAvatar } from '@/components/user-avatar'

Expand Down Expand Up @@ -154,6 +161,7 @@ function IDELink({
}

function MainPanel() {
const [searchFlag] = useEnableSearch()
const { data: healthInfo } = useHealth()
const [{ data }] = useMe()
const isChatEnabled = useIsChatEnabled()
Expand All @@ -168,6 +176,12 @@ function MainPanel() {
await signOut()
setSignOutLoading(false)
}

const onSearch = (question: string) => {
sessionStorage.setItem(SESSION_STORAGE_KEY.SEARCH_INITIAL_MSG, question)
window.open('/search')
}

return (
<div className="lg:mt-[10vh]">
<div className="mx-auto flex w-screen flex-col px-5 py-20 lg:w-auto lg:flex-row lg:justify-center lg:gap-x-10 lg:px-0 lg:py-10">
Expand Down Expand Up @@ -210,6 +224,29 @@ function MainPanel() {
<MenuLink href="/files" icon={<IconCode />} target="_blank">
Code Browser
</MenuLink>
{searchFlag.value && isChatEnabled && (
<Dialog>
<DialogTrigger>
<div className="flex items-center gap-2">
<div className="text-muted-foreground">
<IconSearch />
</div>
<div className="flex cursor-pointer items-center gap-1 text-sm transition-opacity hover:opacity-50">
Search
</div>
</div>
</DialogTrigger>
<DialogContent className="dialog-without-close-btn -mt-48 border-none bg-transparent shadow-none sm:max-w-xl">
<div className="flex flex-col items-center">
<Image src={logoUrl} alt="logo" width={42} />
<h4 className="mb-6 scroll-m-20 text-xl font-semibold tracking-tight text-secondary-foreground">
The Private Search Assistant
</h4>
<TextAreaSearch onSearch={onSearch} />
</div>
</DialogContent>
</Dialog>
)}
<MenuLink icon={<IconLogout />} onClick={handleSignOut}>
<span>Sign out</span>
{signOutLoading && <IconSpinner className="ml-1" />}
Expand Down
4 changes: 4 additions & 0 deletions ee/tabby-ui/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@
.prose-full-width {
max-width: none !important;
}

.dialog-without-close-btn > button {
display: none;
}
Loading

0 comments on commit dfb4495

Please sign in to comment.