-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: chat dialog for talking to repos (#226)
* feat: chat dialog for talking to repos * chat dialog start * add spinner for indexign * shift to react * remove chat UI when the page is changed * base chat layout, design and dp left * it works! * refactor from reviews * add suggested queries * embed events * remove quotes * tests * handle server errors on embedding * fix warnings * still trying to pass these tests * nick's suggestions
- Loading branch information
Showing
16 changed files
with
2,008 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import { RepoQuery } from "../../../repo-query/pages/main"; | ||
import { createHtmlElement } from "../../../utils/createHtmlElement"; | ||
|
||
export const RepoQueryRoot = (ownerName: string, repoName: string) => { | ||
const repoQueryRoot = createHtmlElement("div", { id: "repo-query-root" }); | ||
|
||
ReactDOM.createRoot(repoQueryRoot).render( | ||
<React.StrictMode> | ||
<RepoQuery | ||
ownerName={ownerName} | ||
repoName={repoName} | ||
/> | ||
</React.StrictMode>, | ||
); | ||
|
||
|
||
return repoQueryRoot; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import openSaucedLogoIcon from "../../assets/open-sauced-orange-bg-logo.svg"; | ||
|
||
export const ChatCircle = ({ toggleDialog }: { toggleDialog: () => void }) => ( | ||
<button | ||
onClick={toggleDialog} | ||
onKeyDown={ | ||
e => { | ||
if (e.key === "Enter") { | ||
toggleDialog(); | ||
} | ||
} | ||
} | ||
> | ||
<img | ||
alt="Open Sauced Logo" | ||
className="w-14 h-14 rounded-full fixed bottom-0 right-0 m-8 z-50 cursor-pointer" | ||
id="chat-dialog-button-logo" | ||
src={chrome.runtime.getURL(openSaucedLogoIcon)} | ||
/> | ||
</button> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { useState } from "react"; | ||
import openSaucedLogoIcon from "../../assets/open-sauced-orange-bg-logo.svg"; | ||
import { Home } from "../pages/home"; | ||
import { IndexingPage } from "../pages/indexing"; | ||
import { Chat } from "../pages/chat"; | ||
import { RepoQueryPages } from "../../ts/types"; | ||
|
||
export const Dialog = ({ isOpen, toggleDialog, ownerName, repoName }: { isOpen: boolean, toggleDialog: () => void, ownerName: string, repoName: string }) => { | ||
const [currentPage, setCurrentPage] = useState(RepoQueryPages.Home); | ||
|
||
return ( | ||
<div | ||
className="fixed bottom-20 right-0 m-8 z-50" | ||
id="chat-dialog" | ||
style={{ display: isOpen ? "block" : "none" }} | ||
> | ||
<div | ||
className="flex flex-row justify-between items-center w-96 h-16 rounded-tl-xl rounded-tr-lg bg-slate-800 shadow-lg" | ||
id="chat-dialog-header" | ||
> | ||
<div | ||
className="flex flex-row justify-between w-full pr-4 items-center" | ||
id="chat-dialog-header-left" | ||
> | ||
<div | ||
className="flex flex-row items-center" | ||
id="chat-dialog-header-left-logo-container" | ||
> | ||
<img | ||
alt="OpenSauced logo" | ||
className="w-12 h-12 rounded-full ml-4" | ||
id="chat-dialog-header-left-logo" | ||
src={`${chrome.runtime.getURL(openSaucedLogoIcon)}`} | ||
/> | ||
|
||
<div | ||
className="ml-4" | ||
id="chat-dialog-header-left-text" | ||
> | ||
<div | ||
className="text-lg font-bold text-white" | ||
id="chat-dialog-header-left-text-title" | ||
> | ||
OpenSauced | ||
</div> | ||
|
||
<div | ||
className="text-sm text-gray-400" | ||
id="chat-dialog-header-left-text-subtitle" | ||
> | ||
RepoQuery | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div | ||
className="w-8 h-8 rounded-full bg-gray-200 flex flex-row justify-center items-center ml-4 cursor-pointer" | ||
id="chat-dialog-header-left-close" | ||
role="button" | ||
tabIndex={0} | ||
onClick={toggleDialog} | ||
onKeyDown={ | ||
e => { | ||
if (e.key === "Enter") { | ||
toggleDialog(); | ||
} | ||
} | ||
} | ||
> | ||
<svg | ||
className="w-4 h-4 text-gray-500" | ||
fill="none" | ||
stroke="currentColor" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M6 18L18 6M6 6l12 12" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div | ||
className="flex flex-col w-96 h-96 rounded-bl-xl rounded-br-lg bg-white shadow-lg" | ||
id="chat-dialog-body" | ||
> | ||
{ | ||
currentPage === RepoQueryPages.Home | ||
? ( | ||
<Home | ||
ownerName={ownerName} | ||
repoName={repoName} | ||
setCurrentPage={setCurrentPage} | ||
/> | ||
) | ||
: currentPage === RepoQueryPages.Indexing | ||
? ( | ||
<IndexingPage | ||
ownerName={ownerName} | ||
repoName={repoName} | ||
setCurrentPage={setCurrentPage} | ||
/> | ||
) | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
: currentPage === RepoQueryPages.Chat | ||
? ( | ||
<Chat | ||
ownerName={ownerName} | ||
repoName={repoName} | ||
/> | ||
) | ||
: null | ||
} | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.