Skip to content

Commit

Permalink
better zero state for file list (All-Hands-AI#3213)
Browse files Browse the repository at this point in the history
* better zero state for file list

* Lint, cleanup, and update branch

---------

Co-authored-by: amanape <[email protected]>
  • Loading branch information
rbren and amanape authored Aug 1, 2024
1 parent 286f100 commit 8d11e0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 10 additions & 0 deletions frontend/src/components/file-explorer/ExplorerTree.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import React from "react";
import { useTranslation } from "react-i18next";
import TreeNode from "./TreeNode";
import { I18nKey } from "#/i18n/declaration";

interface ExplorerTreeProps {
files: string[];
defaultOpen?: boolean;
}

function ExplorerTree({ files, defaultOpen = false }: ExplorerTreeProps) {
const { t } = useTranslation();
if (files.length === 0) {
return (
<div className="text-sm text-gray-400 pt-4">
{t(I18nKey.EXPLORER$EMPTY_WORKSPACE_MESSAGE)}
</div>
);
}
return (
<div className="w-full overflow-x-auto h-full pt-[4px]">
{files.map((file) => (
Expand Down
17 changes: 4 additions & 13 deletions frontend/src/components/file-explorer/FileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ function FileExplorer() {
try {
const fileList = await listFiles("/");
setFiles(fileList);
if (fileList.length === 0) {
toast.info(t(I18nKey.EXPLORER$EMPTY_WORKSPACE_MESSAGE));
}
} catch (error) {
toast.error("refresh-error", t(I18nKey.EXPLORER$REFRESH_ERROR_MESSAGE));
}
Expand Down Expand Up @@ -188,10 +185,6 @@ function FileExplorer() {
};
}, []);

if (!files.length) {
return null;
}

return (
<div className="relative h-full">
{isDragging && (
Expand Down Expand Up @@ -219,19 +212,17 @@ function FileExplorer() {
isHidden ? "w-12" : "w-60",
)}
>
<div className="flex flex-col relative h-full p-2">
<div className="flex flex-col relative h-full px-3 py-2">
<div className="sticky top-0 bg-neutral-800 z-10">
<div
className={twMerge(
"flex items-center mt-2 mb-1 p-2",
"flex items-center",
isHidden ? "justify-center" : "justify-between",
)}
>
{!isHidden && (
<div className="ml-1 text-neutral-300 font-bold text-sm">
<div className="ml-1 text-neutral-300 font-bold text-sm">
{t(I18nKey.EXPLORER$LABEL_WORKSPACE)}
</div>
<div className="text-neutral-300 font-bold text-sm">
{t(I18nKey.EXPLORER$LABEL_WORKSPACE)}
</div>
)}
<ExplorerActions
Expand Down

0 comments on commit 8d11e0e

Please sign in to comment.