import bookmarks from other platforms + many other improvements

This commit is contained in:
daniel31x13
2023-10-03 14:34:13 +03:30
parent 8fc8874063
commit f15e298cc3
13 changed files with 216 additions and 172 deletions
@@ -82,7 +82,7 @@ export default function DeleteCollection({
</div>
<div className="flex flex-col gap-3">
<p className="text-black dark:text-white select-none text-center">
<p className="text-black dark:text-white text-center">
To confirm, type &quot;
<span className="font-bold">{collection.name}</span>
&quot; in the box below:
+71 -54
View File
@@ -7,8 +7,8 @@ import useLinkStore from "@/store/links";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import RequiredBadge from "../../RequiredBadge";
import { useSession } from "next-auth/react";
// import useCollectionStore from "@/store/collections";
// import { useRouter } from "next/router";
import useCollectionStore from "@/store/collections";
import { useRouter } from "next/router";
import SubmitButton from "../../SubmitButton";
import { toast } from "react-hot-toast";
import Link from "next/link";
@@ -55,27 +55,40 @@ export default function AddOrEditLink({
const { updateLink, addLink } = useLinkStore();
// const router = useRouter();
const router = useRouter();
const { collections } = useCollectionStore();
// const { collections } = useCollectionStore();
useEffect(() => {
if (method === "CREATE") {
if (router.query.id) {
const currentCollection = collections.find(
(e) => e.id == Number(router.query.id)
);
// useEffect(() => {
// if (router.query.id) {
// const currentCollection = collections.find(
// (e) => e.id == Number(router.query.id)
// );
// if (currentCollection && currentCollection.ownerId)
// setLink({
// ...link,
// collection: {
// id: currentCollection.id,
// name: currentCollection.name,
// ownerId: currentCollection.ownerId,
// },
// });
// }
// }, []);
if (
currentCollection &&
currentCollection.ownerId &&
router.asPath.startsWith("/collections/")
)
setLink({
...link,
collection: {
id: currentCollection.id,
name: currentCollection.name,
ownerId: currentCollection.ownerId,
},
});
} else
setLink({
...link,
collection: {
// id: ,
name: "Unorganized",
ownerId: data?.user.id as number,
},
});
}
}, []);
const setTags = (e: any) => {
const tagNames = e.map((e: any) => {
@@ -147,27 +160,29 @@ export default function AddOrEditLink({
<p className="text-sm text-black dark:text-white mb-2">
Collection
</p>
<CollectionSelection
onChange={setCollection}
// defaultValue={{
// label: link.collection.name,
// value: link.collection.id,
// }}
defaultValue={
link.collection.id
? {
value: link.collection.id,
label: link.collection.name,
}
: {
value: null as unknown as number,
label: "Unorganized",
}
}
/>
{link.collection.name ? (
<CollectionSelection
onChange={setCollection}
// defaultValue={{
// label: link.collection.name,
// value: link.collection.id,
// }}
defaultValue={
link.collection.id
? {
value: link.collection.id,
label: link.collection.name,
}
: {
value: null as unknown as number,
label: "Unorganized",
}
}
/>
) : null}
</div>
</div>
) : null}
) : undefined}
{optionsExpanded ? (
<div>
@@ -187,20 +202,22 @@ export default function AddOrEditLink({
<p className="text-sm text-black dark:text-white mb-2">
Collection
</p>
<CollectionSelection
onChange={setCollection}
defaultValue={
link.collection.name && link.collection.id
? {
value: link.collection.id,
label: link.collection.name,
}
: {
value: null as unknown as number,
label: "Unorganized",
}
}
/>
{link.collection.name ? (
<CollectionSelection
onChange={setCollection}
defaultValue={
link.collection.name && link.collection.id
? {
value: link.collection.id,
label: link.collection.name,
}
: {
value: null as unknown as number,
label: "Unorganized",
}
}
/>
) : undefined}
</div>
) : undefined}
+10 -11
View File
@@ -50,7 +50,7 @@ export default function PrivacySettings({
return wordsArray;
};
const postJSONFile = async (e: any) => {
const postBookmarkFile = async (e: any) => {
const file: File = e.target.files[0];
if (file) {
@@ -156,9 +156,7 @@ export default function PrivacySettings({
</div>
<div className="mt-5">
<p className="text-sm text-black dark:text-white mb-2">
Import/Export Data
</p>
<p className="text-sm text-black dark:text-white mb-2">Import Data</p>
<div className="flex gap-2">
<div
@@ -178,22 +176,22 @@ export default function PrivacySettings({
const target = e.target as HTMLInputElement;
if (target.id !== "import-dropdown") setImportDropdown(false);
}}
className={`absolute top-7 left-0 w-36 py-1 shadow-md border border-sky-100 dark:border-neutral-700 bg-gray-50 dark:bg-neutral-800 rounded-md flex flex-col z-20`}
className={`absolute top-7 left-0 w-48 py-1 shadow-md border border-sky-100 dark:border-neutral-700 bg-gray-50 dark:bg-neutral-800 rounded-md flex flex-col z-20`}
>
<div className="cursor-pointer rounded-md">
<label
htmlFor="import-file"
title="JSON"
title="HTML File"
className="flex items-center gap-2 py-1 px-2 hover:bg-slate-200 hover:dark:bg-neutral-700 duration-100 cursor-pointer"
>
Linkwarden
Bookmarks HTML file...
<input
type="file"
name="photo"
id="import-file"
accept=".json"
accept=".html"
className="hidden"
onChange={postJSONFile}
onChange={postBookmarkFile}
/>
</label>
</div>
@@ -201,11 +199,12 @@ export default function PrivacySettings({
) : null}
</div>
<Link className="w-fit" href="/api/migration">
{/* Commented out for now. */}
{/* <Link className="w-fit" href="/api/migration">
<div className="border border-slate-200 dark:border-neutral-700 rounded-md bg-white dark:bg-neutral-800 px-2 text-center select-none cursor-pointer duration-100 hover:border-sky-300 hover:dark:border-sky-600">
Export Data
</div>
</Link>
</Link> */}
</div>
</div>