fixes
This commit is contained in:
parent
2b83522eaa
commit
1260e8c093
|
@ -61,8 +61,7 @@ export default function Dropdown({
|
||||||
}, [points, dropdownHeight]);
|
}, [points, dropdownHeight]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!points ||
|
(!points || pos) && (
|
||||||
(pos && (
|
|
||||||
<ClickAwayHandler
|
<ClickAwayHandler
|
||||||
onMount={(e) => {
|
onMount={(e) => {
|
||||||
setDropdownHeight(e.height);
|
setDropdownHeight(e.height);
|
||||||
|
@ -104,6 +103,6 @@ export default function Dropdown({
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ClickAwayHandler>
|
</ClickAwayHandler>
|
||||||
))
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ export default function CollectionSelection({
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
options={options}
|
options={options}
|
||||||
styles={styles}
|
styles={styles}
|
||||||
defaultValue={showDefaultValue && defaultValue}
|
defaultValue={showDefaultValue ? defaultValue : null}
|
||||||
components={{
|
components={{
|
||||||
Option: customOption,
|
Option: customOption,
|
||||||
}}
|
}}
|
||||||
|
@ -120,7 +120,7 @@ export default function CollectionSelection({
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
options={options}
|
options={options}
|
||||||
styles={styles}
|
styles={styles}
|
||||||
defaultValue={showDefaultValue && defaultValue}
|
defaultValue={showDefaultValue ? defaultValue : null}
|
||||||
components={{
|
components={{
|
||||||
Option: customOption,
|
Option: customOption,
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -12,22 +12,20 @@ import { useTranslation } from "next-i18next";
|
||||||
import { useUser } from "@/hooks/store/user";
|
import { useUser } from "@/hooks/store/user";
|
||||||
import { useDeleteLink, useUpdateLink } from "@/hooks/store/links";
|
import { useDeleteLink, useUpdateLink } from "@/hooks/store/links";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
import LinkDetailModal from "@/components/ModalContent/LinkDetailModal";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
link: LinkIncludingShortenedCollectionAndTags;
|
link: LinkIncludingShortenedCollectionAndTags;
|
||||||
collection: CollectionIncludingMembersAndLinkCount;
|
collection: CollectionIncludingMembersAndLinkCount;
|
||||||
position?: string;
|
position?: string;
|
||||||
toggleShowInfo?: () => void;
|
|
||||||
linkInfo?: boolean;
|
|
||||||
alignToTop?: boolean;
|
alignToTop?: boolean;
|
||||||
flipDropdown?: boolean;
|
flipDropdown?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LinkActions({
|
export default function LinkActions({
|
||||||
link,
|
link,
|
||||||
toggleShowInfo,
|
|
||||||
position,
|
position,
|
||||||
linkInfo,
|
|
||||||
alignToTop,
|
alignToTop,
|
||||||
flipDropdown,
|
flipDropdown,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
@ -36,6 +34,7 @@ export default function LinkActions({
|
||||||
const permissions = usePermissions(link.collection.id as number);
|
const permissions = usePermissions(link.collection.id as number);
|
||||||
|
|
||||||
const [editLinkModal, setEditLinkModal] = useState(false);
|
const [editLinkModal, setEditLinkModal] = useState(false);
|
||||||
|
const [linkDetailModal, setLinkDetailModal] = useState(false);
|
||||||
const [deleteLinkModal, setDeleteLinkModal] = useState(false);
|
const [deleteLinkModal, setDeleteLinkModal] = useState(false);
|
||||||
const [preservedFormatsModal, setPreservedFormatsModal] = useState(false);
|
const [preservedFormatsModal, setPreservedFormatsModal] = useState(false);
|
||||||
|
|
||||||
|
@ -70,8 +69,24 @@ export default function LinkActions({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{isPublicRoute ? (
|
||||||
|
<div
|
||||||
|
className={`absolute ${position || "top-3 right-3"} ${
|
||||||
|
alignToTop ? "" : "dropdown-end"
|
||||||
|
} z-20`}
|
||||||
|
onClick={() => setLinkDetailModal(true)}
|
||||||
|
>
|
||||||
|
<div className="btn btn-ghost btn-sm btn-square text-neutral">
|
||||||
|
<i title="More" className="bi-three-dots text-xl" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<div
|
<div
|
||||||
className={`dropdown dropdown-left absolute ${
|
className={`dropdown dropdown-left absolute ${
|
||||||
position || "top-3 right-3"
|
position || "top-3 right-3"
|
||||||
|
@ -90,6 +105,8 @@ export default function LinkActions({
|
||||||
alignToTop ? "" : "translate-y-10"
|
alignToTop ? "" : "translate-y-10"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
{permissions === true ||
|
||||||
|
(permissions?.canUpdate && (
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
role="button"
|
role="button"
|
||||||
|
@ -105,21 +122,20 @@ export default function LinkActions({
|
||||||
: t("pin_to_dashboard")}
|
: t("pin_to_dashboard")}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{linkInfo !== undefined && toggleShowInfo && (
|
))}
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
(document?.activeElement as HTMLElement)?.blur();
|
(document?.activeElement as HTMLElement)?.blur();
|
||||||
toggleShowInfo();
|
setLinkDetailModal(true);
|
||||||
}}
|
}}
|
||||||
className="whitespace-nowrap"
|
className="whitespace-nowrap"
|
||||||
>
|
>
|
||||||
{!linkInfo ? t("show_link_details") : t("hide_link_details")}
|
{t("show_link_details")}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)}
|
|
||||||
{(permissions === true || permissions?.canUpdate) && (
|
{(permissions === true || permissions?.canUpdate) && (
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
|
@ -183,7 +199,7 @@ export default function LinkActions({
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
{editLinkModal && (
|
{editLinkModal && (
|
||||||
<EditLinkModal
|
<EditLinkModal
|
||||||
onClose={() => setEditLinkModal(false)}
|
onClose={() => setEditLinkModal(false)}
|
||||||
|
@ -202,6 +218,13 @@ export default function LinkActions({
|
||||||
link={link}
|
link={link}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{linkDetailModal && (
|
||||||
|
<LinkDetailModal
|
||||||
|
onClose={() => setLinkDetailModal(false)}
|
||||||
|
onEdit={() => setEditLinkModal(true)}
|
||||||
|
link={link}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ export default function EditCollectionSharingModal({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{collection.isPublic && (
|
{collection.isPublic && (
|
||||||
<div className={permissions === true ? "pl-5" : ""}>
|
<div>
|
||||||
<p className="mb-2">{t("sharable_link_guide")}</p>
|
<p className="mb-2">{t("sharable_link_guide")}</p>
|
||||||
<div className="w-full hide-scrollbar overflow-x-auto whitespace-nowrap rounded-md p-2 bg-base-200 border-neutral-content border-solid border flex items-center gap-2 justify-between">
|
<div className="w-full hide-scrollbar overflow-x-auto whitespace-nowrap rounded-md p-2 bg-base-200 border-neutral-content border-solid border flex items-center gap-2 justify-between">
|
||||||
{publicCollectionURL}
|
{publicCollectionURL}
|
||||||
|
|
|
@ -150,7 +150,7 @@ export default function UploadFileModal({ onClose }: Props) {
|
||||||
<label className="btn h-10 btn-sm w-full border border-neutral-content hover:border-neutral-content flex justify-between">
|
<label className="btn h-10 btn-sm w-full border border-neutral-content hover:border-neutral-content flex justify-between">
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept=".pdf,.png,.jpg,.jpeg,.html"
|
accept=".pdf,.png,.jpg,.jpeg"
|
||||||
className="cursor-pointer custom-file-input"
|
className="cursor-pointer custom-file-input"
|
||||||
onChange={(e) => e.target.files && setFile(e.target.files[0])}
|
onChange={(e) => e.target.files && setFile(e.target.files[0])}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -21,9 +21,8 @@ export default function ToggleDarkMode({ className }: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (theme) {
|
if (theme) {
|
||||||
updateSettings({ theme });
|
updateSettings({ theme });
|
||||||
localStorage.setItem("theme", theme);
|
|
||||||
}
|
}
|
||||||
}, [theme, updateSettings]);
|
}, [theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -22,32 +22,5 @@ export default async function exportData(userId: number) {
|
||||||
|
|
||||||
const { password, id, ...userData } = user;
|
const { password, id, ...userData } = user;
|
||||||
|
|
||||||
function redactIds(data: object | object[]): void {
|
|
||||||
if (Array.isArray(data)) {
|
|
||||||
data.forEach((item) => redactIds(item));
|
|
||||||
} else if (data !== null && typeof data === "object") {
|
|
||||||
const fieldsToRedact = ["id", "parentId", "collectionId", "ownerId"];
|
|
||||||
|
|
||||||
fieldsToRedact.forEach((field) => {
|
|
||||||
if (field in data) {
|
|
||||||
delete (data as any)[field];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Recursively call redactIds for each property that is an object or an array
|
|
||||||
Object.keys(data).forEach((key) => {
|
|
||||||
const value = (data as any)[key];
|
|
||||||
if (
|
|
||||||
value !== null &&
|
|
||||||
(typeof value === "object" || Array.isArray(value))
|
|
||||||
) {
|
|
||||||
redactIds(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
redactIds(userData);
|
|
||||||
|
|
||||||
return { response: userData, status: 200 };
|
return { response: userData, status: 200 };
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ const generatePreview = async (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.resize(1280, Jimp.AUTO).quality(20);
|
image.resize(1000, Jimp.AUTO).quality(20);
|
||||||
const processedBuffer = await image.getBufferAsync(Jimp.MIME_JPEG);
|
const processedBuffer = await image.getBufferAsync(Jimp.MIME_JPEG);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -135,7 +135,7 @@ export default function Dashboard() {
|
||||||
|
|
||||||
<DashboardItem
|
<DashboardItem
|
||||||
name={tags.length === 1 ? t("tag") : t("tags")}
|
name={tags.length === 1 ? t("tag") : t("tags")}
|
||||||
value={tags.length * numberOfLinks}
|
value={tags.length}
|
||||||
icon={"bi-hash"}
|
icon={"bi-hash"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -88,8 +88,8 @@ export default function PublicCollections() {
|
||||||
(localStorage.getItem("viewMode") as ViewMode) || ViewMode.Card
|
(localStorage.getItem("viewMode") as ViewMode) || ViewMode.Card
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!collection) return null;
|
if (!collection) return <></>;
|
||||||
|
else
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="h-96"
|
className="h-96"
|
||||||
|
@ -227,7 +227,9 @@ export default function PublicCollections() {
|
||||||
placeholderCount={1}
|
placeholderCount={1}
|
||||||
useData={data}
|
useData={data}
|
||||||
/>
|
/>
|
||||||
{!data.isLoading && links && !links[0] && <p>{t("nothing_found")}</p>}
|
{!data.isLoading && links && !links[0] && (
|
||||||
|
<p>{t("nothing_found")}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* <p className="text-center text-neutral">
|
{/* <p className="text-center text-neutral">
|
||||||
List created with <span className="text-black">Linkwarden.</span>
|
List created with <span className="text-black">Linkwarden.</span>
|
||||||
|
|
Ŝarĝante…
Reference in New Issue