Skip to content

Commit

Permalink
hide folder if data empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mckaywrigley committed Jan 16, 2024
1 parent 1e45dde commit 7269cac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/sidebar/items/all/sidebar-delete-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const SidebarDeleteItem: FC<SidebarDeleteItemProps> = ({

const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.key === "Enter") {
e.stopPropagation()
buttonRef.current?.click()
}
}
Expand Down
5 changes: 4 additions & 1 deletion components/sidebar/sidebar-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const SidebarContent: FC<SidebarContentProps> = ({
// Subtract 50px for the height of the workspace settings
<div className="flex max-h-[calc(100%-50px)] grow flex-col">
<div className="mt-2 flex items-center">
<SidebarCreateButtons contentType={contentType} />
<SidebarCreateButtons
contentType={contentType}
hasData={data.length > 0}
/>
</div>

<div className="mt-2">
Expand Down
12 changes: 8 additions & 4 deletions components/sidebar/sidebar-create-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import { CreateTool } from "./items/tools/create-tool"

interface SidebarCreateButtonsProps {
contentType: ContentType
hasData: boolean
}

export const SidebarCreateButtons: FC<SidebarCreateButtonsProps> = ({
contentType
contentType,
hasData
}) => {
const { profile, selectedWorkspace, folders, setFolders } =
useContext(ChatbotUIContext)
Expand Down Expand Up @@ -95,9 +97,11 @@ export const SidebarCreateButtons: FC<SidebarCreateButtonsProps> = ({
contentType.slice(1, contentType.length - 1)}
</Button>

<Button className="h-[36px] w-[36px] p-1" onClick={handleCreateFolder}>
<IconFolderPlus size={20} />
</Button>
{hasData && (
<Button className="h-[36px] w-[36px] p-1" onClick={handleCreateFolder}>
<IconFolderPlus size={20} />
</Button>
)}

{isCreatingPrompt && (
<CreatePrompt
Expand Down

0 comments on commit 7269cac

Please sign in to comment.