diff --git a/api/v2/collection_service.go b/api/v2/collection_service.go index a99f5d3..049c512 100644 --- a/api/v2/collection_service.go +++ b/api/v2/collection_service.go @@ -11,6 +11,7 @@ import ( apiv2pb "github.com/boojack/slash/proto/gen/api/v2" storepb "github.com/boojack/slash/proto/gen/store" "github.com/boojack/slash/server/metric" + "github.com/boojack/slash/server/service/license" "github.com/boojack/slash/store" ) @@ -98,6 +99,16 @@ func (s *APIV2Service) GetCollectionByName(ctx context.Context, request *apiv2pb } func (s *APIV2Service) CreateCollection(ctx context.Context, request *apiv2pb.CreateCollectionRequest) (*apiv2pb.CreateCollectionResponse, error) { + if !s.LicenseService.IsFeatureEnabled(license.FeatureTypeUnlimitedAccounts) { + collections, err := s.Store.ListCollections(ctx, &store.FindCollection{}) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get collection list, err: %v", err) + } + if len(collections) >= 5 { + return nil, status.Errorf(codes.PermissionDenied, "Maximum number of collections reached") + } + } + userID := ctx.Value(userIDContextKey).(int32) collection := &storepb.Collection{ CreatorId: userID, diff --git a/frontend/web/src/components/CreateShortcutDrawer.tsx b/frontend/web/src/components/CreateShortcutDrawer.tsx index cb60514..da93ebc 100644 --- a/frontend/web/src/components/CreateShortcutDrawer.tsx +++ b/frontend/web/src/components/CreateShortcutDrawer.tsx @@ -54,7 +54,6 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { ...initialShortcut, }, }); - const [showAdditionalFields, setShowAdditionalFields] = useState(false); const [showOpenGraphMetadata, setShowOpenGraphMetadata] = useState(false); const [tag, setTag] = useState(""); const tagSuggestions = uniq(shortcutList.map((shortcut) => shortcut.tags).flat()); @@ -175,7 +174,7 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { }; const handleSaveBtnClick = async () => { - if (!state.shortcutCreate.name || !state.shortcutCreate.link) { + if (!state.shortcutCreate.name || !state.shortcutCreate.title || !state.shortcutCreate.link) { toast.error("Please fill in required fields."); return; } @@ -224,7 +223,7 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { @@ -232,19 +231,41 @@ const CreateShortcutDrawer: React.FC = (props: Props) => {
- Destination URL * + Link *
+
+ + Title * + + +
+
+ Description + +
Tags - + {tagSuggestions.length > 0 && (
@@ -276,47 +297,7 @@ const CreateShortcutDrawer: React.FC = (props: Props) => {

More -
-
setShowAdditionalFields(!showAdditionalFields)} - > - Additional fields - -
- {showAdditionalFields && ( -
-
- Title - -
-
- Description - -
-
- )} -
-
+