Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

add options to replace other preserved formats

Kha Nguyen91e337ea8c66
diff --git a/apps/web/components/LinkDetails.tsx b/apps/web/components/LinkDetails.tsx
index f737ea4e..12038744 100644
--- a/apps/web/components/LinkDetails.tsx
+++ b/apps/web/components/LinkDetails.tsx
@@ -521,6 +521,7 @@ export default function LinkDetails({
format={ArchivedFormat.monolith}
link={link}
downloadable={true}
+ replaceable={!isPublicRoute && (permissions === true || permissions?.canUpdate)}
/>
<Separator className="my-3" />
</>
@@ -538,6 +539,7 @@ export default function LinkDetails({
}
link={link}
downloadable={true}
+ replaceable={!isPublicRoute && (permissions === true || permissions?.canUpdate)}
/>
<Separator className="my-3" />
</>
@@ -551,6 +553,7 @@ export default function LinkDetails({
format={ArchivedFormat.pdf}
link={link}
downloadable={true}
+ replaceable={!isPublicRoute && (permissions === true || permissions?.canUpdate)}
/>
<Separator className="my-3" />
</>
diff --git a/apps/web/components/PreserverdFormatRow.tsx b/apps/web/components/PreserverdFormatRow.tsx
index 73931c28..3ea6a15e 100644
--- a/apps/web/components/PreserverdFormatRow.tsx
+++ b/apps/web/components/PreserverdFormatRow.tsx
@@ -13,6 +13,7 @@ type Props = {
format: ArchivedFormat;
link: LinkIncludingShortenedCollectionAndTags;
downloadable?: boolean;
+ replaceable?: boolean;
};
export default function PreservedFormatRow({
@@ -21,6 +22,7 @@ export default function PreservedFormatRow({
format,
link,
downloadable,
+ replaceable,
}: Props) {
const router = useRouter();
@@ -63,13 +65,21 @@ export default function PreservedFormatRow({
</Button>
) : undefined}
- {!isPublic && format === ArchivedFormat.monolith ? (
+ {!isPublic && replaceable ? (
<Button asChild variant="ghost" size="icon">
<label className="cursor-pointer">
<i className="bi-cloud-arrow-up text-xl text-neutral" />
<input
type="file"
- accept="text/html,.html"
+ accept={
+ format === ArchivedFormat.monolith
+ ? "text/html,.html"
+ : format === ArchivedFormat.pdf
+ ? "application/pdf,.pdf"
+ : format === ArchivedFormat.png || format === ArchivedFormat.jpeg
+ ? "image/png,image/jpeg,.png,.jpg,.jpeg"
+ : undefined
+ }
className="hidden"
onChange={async (e) => {
const file = e.target.files?.[0];
@@ -86,12 +96,12 @@ export default function PreservedFormatRow({
);
if (res.ok) {
- toast.success("Replaced webpage HTML");
+ toast.success("Replaced file");
// refresh page data
router.replace(router.asPath);
} else {
const data = await res.json().catch(() => ({}));
- toast.error(data?.response || "Failed to replace HTML");
+ toast.error(data?.response || "Failed to replace file");
}
}}
/>