This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into stefankracht/dir-1027-make-403-redirect-to-l…
…ogout-path
- Loading branch information
Showing
18 changed files
with
254 additions
and
128 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
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
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,67 @@ | ||
import { FC, Fragment } from "react"; | ||
import { | ||
FilepickerClose, | ||
FilepickerListItem, | ||
FilepickerSeparator, | ||
} from "~/design/Filepicker"; | ||
|
||
import { NodeSchemaType } from "~/api/tree/schema/node"; | ||
import { fileTypeToIcon } from "~/api/tree/utils"; | ||
import { twMergeClsx } from "~/util/helpers"; | ||
|
||
export type FileListProps = { | ||
results: NodeSchemaType[]; | ||
selectable: ((node: NodeSchemaType) => boolean) | undefined; | ||
setPath: (path: string) => void; | ||
setInputValue: (value: string) => void; | ||
onChange: (path: string) => void; | ||
}; | ||
|
||
export const FileList: FC<FileListProps> = ({ | ||
results, | ||
selectable, | ||
setPath, | ||
setInputValue, | ||
onChange, | ||
}) => ( | ||
<> | ||
{results.map((file, index) => { | ||
const isSelectable = selectable?.(file) ?? true; | ||
const isLastListItem = index === results.length - 1; | ||
return ( | ||
<Fragment key={file.name}> | ||
{file.type === "directory" ? ( | ||
<div | ||
onClick={() => { | ||
setPath(file.path); | ||
}} | ||
className="h-auto w-full cursor-pointer text-gray-11 hover:underline focus:bg-transparent focus:ring-0 focus:ring-transparent focus:ring-offset-0 dark:text-gray-dark-11 dark:focus:bg-transparent" | ||
> | ||
<FilepickerListItem icon={fileTypeToIcon(file.type)}> | ||
{file.name} | ||
</FilepickerListItem> | ||
</div> | ||
) : ( | ||
<FilepickerClose | ||
className={twMergeClsx( | ||
"h-auto w-full text-gray-11 hover:underline dark:text-gray-dark-11", | ||
!isSelectable && "cursor-not-allowed opacity-70" | ||
)} | ||
disabled={!isSelectable} | ||
onClick={() => { | ||
setPath(file.parent); | ||
setInputValue(file.path); | ||
onChange?.(file.path); | ||
}} | ||
> | ||
<FilepickerListItem icon={fileTypeToIcon(file.type)}> | ||
{file.name} | ||
</FilepickerListItem> | ||
</FilepickerClose> | ||
)} | ||
{!isLastListItem && <FilepickerSeparator />} | ||
</Fragment> | ||
); | ||
})} | ||
</> | ||
); |
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,45 @@ | ||
import { Breadcrumb, BreadcrumbRoot } from "~/design/Breadcrumbs"; | ||
|
||
import { FC } from "react"; | ||
import { Home } from "lucide-react"; | ||
|
||
export type FilePathSegmentsProps = { | ||
segments: { | ||
relative: string; | ||
absolute: string; | ||
}[]; | ||
setPath: (path: string) => void; | ||
}; | ||
|
||
export const FilePathSegments: FC<FilePathSegmentsProps> = ({ | ||
segments, | ||
setPath, | ||
}) => ( | ||
<BreadcrumbRoot className="py-3"> | ||
<Breadcrumb | ||
noArrow | ||
onClick={() => { | ||
setPath("/"); | ||
}} | ||
className="h-5 hover:underline" | ||
> | ||
<Home /> | ||
</Breadcrumb> | ||
{segments.map((file) => { | ||
const isEmpty = file.absolute === ""; | ||
|
||
if (isEmpty) return null; | ||
return ( | ||
<Breadcrumb | ||
key={file.relative} | ||
onClick={() => { | ||
setPath(file.absolute); | ||
}} | ||
className="h-5 hover:underline" | ||
> | ||
{file.relative} | ||
</Breadcrumb> | ||
); | ||
})} | ||
</BreadcrumbRoot> | ||
); |
Oops, something went wrong.