* Public File Sharing This implements public file sharing (read-only) with and without passwords (#57). It also fixes a problem with filenames including special characters like `#` not working properly (#71). You can share a directory or a single file, by using the new share icon on the right of the directories/files, and click on it to manage an existing file share (setting a new password, or deleting the file share). There is some other minor cleanup and other copy updates in the README. Closes #57 Fixes #71 * Hide UI elements when sharing isn't allowed
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
interface FilesBreadcrumbProps {
|
|
path: string;
|
|
isShowingNotes?: boolean;
|
|
isShowingPhotos?: boolean;
|
|
fileShareId?: string;
|
|
}
|
|
|
|
export default function FilesBreadcrumb({ path, isShowingNotes, isShowingPhotos, fileShareId }: FilesBreadcrumbProps) {
|
|
let routePath = fileShareId ? `file-share/${fileShareId}` : 'files';
|
|
let rootPath = '/';
|
|
let itemPluralLabel = 'files';
|
|
|
|
if (isShowingNotes) {
|
|
routePath = 'notes';
|
|
itemPluralLabel = 'notes';
|
|
rootPath = '/Notes/';
|
|
} else if (isShowingPhotos) {
|
|
routePath = 'photos';
|
|
itemPluralLabel = 'photos';
|
|
rootPath = '/Photos/';
|
|
}
|
|
|
|
if (path === rootPath) {
|
|
return (
|
|
<h3 class='text-base font-semibold text-white whitespace-nowrap mr-2'>
|
|
All {itemPluralLabel}
|
|
</h3>
|
|
);
|
|
}
|
|
|
|
const pathParts = path.slice(1, -1).split('/');
|
|
|
|
return (
|
|
<h3 class='text-base font-semibold text-white whitespace-nowrap mr-2'>
|
|
{!isShowingNotes && !isShowingPhotos ? <a href={`/${routePath}?path=/`}>All files</a> : null}
|
|
{isShowingNotes ? <a href={`/notes?path=/Notes/`}>All notes</a> : null}
|
|
{isShowingPhotos ? <a href={`/photos?path=/Photos/`}>All photos</a> : null}
|
|
{pathParts.map((part, index) => {
|
|
// Ignore the first directory in special ones
|
|
if (index === 0 && (isShowingNotes || isShowingPhotos)) {
|
|
return null;
|
|
}
|
|
|
|
if (index === pathParts.length - 1) {
|
|
return (
|
|
<>
|
|
<span class='ml-2 text-xs'>/</span>
|
|
<span class='ml-2'>{decodeURIComponent(part)}</span>
|
|
</>
|
|
);
|
|
}
|
|
|
|
const fullPathForPart: string[] = [];
|
|
|
|
for (let pathPartIndex = 0; pathPartIndex <= index; ++pathPartIndex) {
|
|
fullPathForPart.push(pathParts[pathPartIndex]);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<span class='ml-2 text-xs'>/</span>
|
|
<a href={`/${routePath}?path=/${encodeURIComponent(fullPathForPart.join('/'))}/`} class='ml-2'>
|
|
{decodeURIComponent(part)}
|
|
</a>
|
|
</>
|
|
);
|
|
})}
|
|
</h3>
|
|
);
|
|
}
|