Skip to content

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

feat: impl menu item feature locks for non-pro users

thecodrr71c146e1962d
diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.js
index 67887166c..7fb344488 100644
--- a/apps/web/src/components/menu/index.js
+++ b/apps/web/src/components/menu/index.js
@@ -1,7 +1,10 @@
import React from "react";
import { Flex, Box, Text } from "rebass";
+import { useStore as useUserStore } from "../../stores/user-store";
function Menu(props) {
+ const isPremium = useUserStore((store) => store.isPremium);
+
return (
<Flex
id={props.id}
@@ -38,12 +41,16 @@ function Menu(props) {
if (props.closeMenu) {
props.closeMenu();
}
- if (item.onClick) {
+ const onlyPro = item.onlyPro && !isPremium;
+ if (onlyPro && item.onClick) {
item.onClick(props.data);
+ } else {
+ // TODO show the buy dialog
}
}}
flexDirection="row"
alignItems="center"
+ justifyContent="space-between"
py={"8px"}
px={3}
sx={{
@@ -61,6 +68,17 @@ function Menu(props) {
{item.title}
</Text>
)}
+ {item.onlyPro && !isPremium && (
+ <Text
+ fontSize="menu"
+ bg="primary"
+ color="static"
+ px={1}
+ sx={{ borderRadius: "default" }}
+ >
+ Pro
+ </Text>
+ )}
</Flex>
)
)}
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index d0439bc7b..8bccfe942 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -27,10 +27,12 @@ function menuItems(note, context) {
{
title: note.pinned ? "Unpin" : "Pin",
onClick: () => store.pin(note),
+ onlyPro: true,
},
{
title: note.favorite ? "Unfavorite" : "Favorite",
onClick: () => store.favorite(note),
+ onlyPro: true,
},
{ title: "Edit", onClick: () => editorStore.openSession(note) },
{
@@ -43,6 +45,7 @@ function menuItems(note, context) {
unlock(note.id);
}
},
+ onlyPro: true,
},
{
visible: context ? (context.type === "topic" ? true : false) : false,