Don't show select all if there are no links & fix public view

This commit is contained in:
Isaac Wise 2024-02-10 16:45:25 -06:00
parent 325c41254d
commit ebdeedc2ec
4 changed files with 20 additions and 19 deletions

View File

@ -68,7 +68,7 @@ export default function LinkCard({
const ref = useRef<HTMLDivElement>(null);
const isVisible = useOnScreen(ref);
const permissions = usePermissions(collection.id as number);
const permissions = usePermissions(collection?.id as number);
useEffect(() => {
let interval: any;

View File

@ -62,7 +62,7 @@ export default function LinkCardCompact({
);
}, [collections, links]);
const permissions = usePermissions(collection.id as number);
const permissions = usePermissions(collection?.id as number);
const [showInfo, setShowInfo] = useState(false);

View File

@ -43,7 +43,6 @@ export default function Index() {
useState<CollectionIncludingMembersAndLinkCount>();
const permissions = usePermissions(activeCollection?.id as number);
console.log(permissions)
useLinks({ collectionId: Number(router.query.id), sort: sortBy });
@ -307,19 +306,21 @@ export default function Index() {
</div>
<div className="w-full flex justify-between items-center min-h-[32px]">
<div className="flex gap-3 ml-3">
<input
type="checkbox"
className="checkbox checkbox-primary"
onChange={() => handleSelectAll()}
checked={selectedLinks.length === links.length && links.length > 0}
/>
{selectedLinks.length > 0 && (
<span>
{selectedLinks.length} {selectedLinks.length === 1 ? 'link' : 'links'} selected
</span>
)}
</div>
{links.length > 0 && (
<div className="flex gap-3 ml-3">
<input
type="checkbox"
className="checkbox checkbox-primary"
onChange={() => handleSelectAll()}
checked={selectedLinks.length === links.length && links.length > 0}
/>
{selectedLinks.length > 0 && (
<span>
{selectedLinks.length} {selectedLinks.length === 1 ? 'link' : 'links'} selected
</span>
)}
</div>
)}
<div className="flex gap-3">
{selectedLinks.length > 0 && (permissions === true || permissions?.canUpdate) &&
<button onClick={() => setBulkEditLinksModal(true)} className="btn btn-sm btn-accent dark:border-violet-400 text-white w-fit ml-auto">

View File

@ -145,11 +145,10 @@ export default function Index() {
</p>
<div className="relative">
<div
className={`dropdown dropdown-bottom font-normal ${
activeTag?.name.length && activeTag?.name.length > 8
className={`dropdown dropdown-bottom font-normal ${activeTag?.name.length && activeTag?.name.length > 8
? "dropdown-end"
: ""
}`}
}`}
>
<div
tabIndex={0}
@ -200,6 +199,7 @@ export default function Index() {
</div>
</div>
<LinkComponent
showCheckbox={false}
links={links.filter((e) =>
e.tags.some((e) => e.id === Number(router.query.id))
)}