-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor knowledge code in admin ui (#1008)
* chore: refactor knowledge code in admin ui This should have no effect on logic or UI/UX. it just extracts some subcomponents and abstracts data logic into reusable hooks. Doing this in preparation for thread level knowledge implementations * chore: refactor KnowledgeSourceDetail with similar criteria * chore: move knowledge files around to match the rest of the project * fix: start polling when knowledge source starts syncing * fix: additionally start knowledge polling when source is pending * fix: format
- Loading branch information
1 parent
3711ab9
commit c744850
Showing
12 changed files
with
835 additions
and
705 deletions.
There are no files selected for viewing
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,99 @@ | ||
import { Avatar } from "@radix-ui/react-avatar"; | ||
import { GlobeIcon, PlusIcon, UploadIcon } from "lucide-react"; | ||
|
||
import { KnowledgeSourceType } from "~/lib/model/knowledge"; | ||
import { assetUrl } from "~/lib/utils"; | ||
|
||
import { Button } from "~/components/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "~/components/ui/dropdown-menu"; | ||
|
||
interface AddKnowledgeButtonProps { | ||
disabled?: boolean; | ||
onUploadFiles: () => void; | ||
onAddSource: (sourceType: KnowledgeSourceType) => void; | ||
hasExistingNotion: boolean; | ||
} | ||
|
||
export function AddKnowledgeButton({ | ||
disabled, | ||
onUploadFiles, | ||
onAddSource, | ||
hasExistingNotion, | ||
}: AddKnowledgeButtonProps) { | ||
return ( | ||
<div className="flex justify-end w-full"> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="ghost" | ||
className="flex items-center gap-2" | ||
disabled={disabled} | ||
> | ||
<PlusIcon className="h-5 w-5 text-foreground" /> | ||
Add Knowledge | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent side="top"> | ||
<DropdownMenuItem | ||
onClick={onUploadFiles} | ||
className="cursor-pointer" | ||
> | ||
<div className="flex items-center"> | ||
<UploadIcon className="w-4 h-4 mr-2" /> | ||
Local Files | ||
</div> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
onClick={() => | ||
onAddSource(KnowledgeSourceType.OneDrive) | ||
} | ||
className="cursor-pointer" | ||
> | ||
<div className="flex flex-row justify-center"> | ||
<div className="flex flex-row justify-center"> | ||
<div className="flex items-center justify-center"> | ||
<Avatar className="h-4 w-4 mr-2"> | ||
<img | ||
src={assetUrl("/onedrive.svg")} | ||
alt="OneDrive logo" | ||
/> | ||
</Avatar> | ||
</div> | ||
<span>OneDrive</span> | ||
</div> | ||
</div> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
onClick={() => onAddSource(KnowledgeSourceType.Notion)} | ||
className="cursor-pointer" | ||
disabled={hasExistingNotion} | ||
> | ||
<div className="flex flex-row justify-center"> | ||
<Avatar className="h-4 w-4 mr-2"> | ||
<img | ||
src={assetUrl("/notion.svg")} | ||
alt="Notion logo" | ||
/> | ||
</Avatar> | ||
Notion | ||
</div> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
onClick={() => onAddSource(KnowledgeSourceType.Website)} | ||
className="cursor-pointer" | ||
> | ||
<div className="flex justify-center"> | ||
<GlobeIcon className="w-4 h-4 mr-2" /> | ||
Website | ||
</div> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.