Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add limits to block-level note linking

Abdullah Attaf08c484d4043
diff --git a/apps/web/src/dialogs/note-linking-dialog.tsx b/apps/web/src/dialogs/note-linking-dialog.tsx
index ad7a8af4a..f49047a4b 100644
--- a/apps/web/src/dialogs/note-linking-dialog.tsx
+++ b/apps/web/src/dialogs/note-linking-dialog.tsx
@@ -29,13 +29,18 @@ import {
} from "@notesnook/core";
import { Button, Flex, Text } from "@theme-ui/components";
import { LinkAttributes } from "@notesnook/editor";
-import { NoteResolvedData, ResolvedItem } from "@notesnook/common";
+import {
+ NoteResolvedData,
+ ResolvedItem,
+ useIsFeatureAvailable
+} from "@notesnook/common";
import { Lock } from "../components/icons";
import { ellipsize } from "@notesnook/core";
import { BaseDialogProps, DialogManager } from "../common/dialog-manager";
import { strings } from "@notesnook/intl";
import { Virtuoso } from "react-virtuoso";
import { CustomScrollbarsVirtualList } from "../components/list-container";
+import { BuyDialog } from "./buy-dialog";
export type NoteLinkingDialogProps = BaseDialogProps<LinkAttributes | false> & {
attributes?: LinkAttributes;
@@ -52,6 +57,7 @@ export const NoteLinkingDialog = DialogManager.register(
const [filteredBlocks, setFilteredBlocks] = useState<
ContentBlock[] | undefined
>();
+ const blockLinkingAvailability = useIsFeatureAvailable("blockLinking");
return (
<Dialog
@@ -125,71 +131,89 @@ export const NoteLinkingDialog = DialogManager.register(
{strings.linkNoteSelectedNote()}: {selectedNote.title} (
{strings.clickToDeselect()})
</Button>
- {isNoteLocked ? (
- <Text variant="body" sx={{ mt: 1 }}>
- {strings.noteLockedBlockLink()}
- </Text>
- ) : blocks.length <= 0 ? (
- <Text variant="body" sx={{ mt: 1 }}>
- {strings.noBlocksOnNote()}
- </Text>
- ) : null}
- <Virtuoso
- style={{ height: "100%", width: "100%" }}
- components={{
- Scroller: CustomScrollbarsVirtualList
- }}
- data={filteredBlocks || blocks}
- context={{ items: filteredBlocks || blocks }}
- itemContent={(_, item) => {
- return (
- <Button
- variant="menuitem"
- sx={{
- p: 1,
- width: "100%",
- textAlign: "left",
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center",
- borderBottom: "1px solid var(--border)"
- }}
- onClick={() => {
- props.onClose({
- title: selectedNote.title,
- href: createInternalLink("note", selectedNote.id, {
- blockId: item.id
- })
- });
- }}
- >
- <Text
- variant="body"
+
+ {blockLinkingAvailability?.isAllowed ? (
+ <>
+ {isNoteLocked ? (
+ <Text variant="body" sx={{ mt: 1 }}>
+ {strings.noteLockedBlockLink()}
+ </Text>
+ ) : blocks.length <= 0 ? (
+ <Text variant="body" sx={{ mt: 1 }}>
+ {strings.noBlocksOnNote()}
+ </Text>
+ ) : null}
+ <Virtuoso
+ style={{ height: "100%", width: "100%" }}
+ components={{
+ Scroller: CustomScrollbarsVirtualList
+ }}
+ data={filteredBlocks || blocks}
+ context={{ items: filteredBlocks || blocks }}
+ itemContent={(_, item) => (
+ <Button
+ variant="menuitem"
sx={{
- fontFamily: "monospace",
- whiteSpace: "pre-wrap"
+ p: 1,
+ width: "100%",
+ textAlign: "left",
+ display: "flex",
+ justifyContent: "space-between",
+ alignItems: "center",
+ borderBottom: "1px solid var(--border)"
}}
- >
- {ellipsize(item.content, 200, "end").trim() ||
- strings.linkNoteEmptyBlock()}
- </Text>
- <Text
- variant="subBody"
- sx={{
- bg: "background-secondary",
- flexShrink: 0,
- p: "small",
- px: 1,
- borderRadius: "default",
- alignSelf: "flex-start"
+ onClick={() => {
+ props.onClose({
+ title: selectedNote.title,
+ href: createInternalLink("note", selectedNote.id, {
+ blockId: item.id
+ })
+ });
}}
>
- {item.type.toUpperCase()}
- </Text>
- </Button>
- );
- }}
- />
+ <Text
+ variant="body"
+ sx={{
+ fontFamily: "monospace",
+ whiteSpace: "pre-wrap"
+ }}
+ >
+ {ellipsize(item.content, 200, "end").trim() ||
+ strings.linkNoteEmptyBlock()}
+ </Text>
+ <Text
+ variant="subBody"
+ sx={{
+ bg: "background-secondary",
+ flexShrink: 0,
+ p: "small",
+ px: 1,
+ borderRadius: "default",
+ alignSelf: "flex-start"
+ }}
+ >
+ {item.type.toUpperCase()}
+ </Text>
+ </Button>
+ )}
+ />
+ </>
+ ) : (
+ <Text variant="body" sx={{ mt: 1 }}>
+ {blockLinkingAvailability?.error}{" "}
+ <Button
+ onClick={() =>
+ BuyDialog.show({
+ plan: blockLinkingAvailability?.availableOn
+ })
+ }
+ variant="anchor"
+ >
+ Upgrade now
+ </Button>
+ .
+ </Text>
+ )}
</>
) : (
<>