diff --git a/api/v2/collection_service.go b/api/v2/collection_service.go index a181bb3..a99f5d3 100644 --- a/api/v2/collection_service.go +++ b/api/v2/collection_service.go @@ -16,13 +16,27 @@ import ( func (s *APIV2Service) ListCollections(ctx context.Context, _ *apiv2pb.ListCollectionsRequest) (*apiv2pb.ListCollectionsResponse, error) { userID := ctx.Value(userIDContextKey).(int32) - find := &store.FindCollection{} - find.CreatorID = &userID - collections, err := s.Store.ListCollections(ctx, find) + collections, err := s.Store.ListCollections(ctx, &store.FindCollection{ + CreatorID: &userID, + VisibilityList: []store.Visibility{ + store.VisibilityPrivate, + }, + }) if err != nil { return nil, status.Errorf(codes.Internal, "failed to get collection list, err: %v", err) } + sharedCollections, err := s.Store.ListCollections(ctx, &store.FindCollection{ + VisibilityList: []store.Visibility{ + store.VisibilityWorkspace, + store.VisibilityPublic, + }, + }) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get collection list, err: %v", err) + } + collections = append(collections, sharedCollections...) + convertedCollections := []*apiv2pb.Collection{} for _, collection := range collections { convertedCollections = append(convertedCollections, convertCollectionFromStore(collection)) diff --git a/frontend/web/src/components/CollectionView.tsx b/frontend/web/src/components/CollectionView.tsx index ebf3e6c..004f681 100644 --- a/frontend/web/src/components/CollectionView.tsx +++ b/frontend/web/src/components/CollectionView.tsx @@ -9,6 +9,7 @@ import useNavigateTo from "@/hooks/useNavigateTo"; import useResponsiveWidth from "@/hooks/useResponsiveWidth"; import { useAppSelector } from "@/stores"; import useCollectionStore from "@/stores/v1/collection"; +import useUserStore from "@/stores/v1/user"; import { Collection } from "@/types/proto/api/v2/collection_service"; import { showCommonDialog } from "./Alert"; import CreateCollectionDialog from "./CreateCollectionDrawer"; @@ -25,12 +26,14 @@ const CollectionView = (props: Props) => { const { t } = useTranslation(); const { sm } = useResponsiveWidth(); const navigateTo = useNavigateTo(); + const currentUser = useUserStore().getCurrentUser(); const collectionStore = useCollectionStore(); const { shortcutList } = useAppSelector((state) => state.shortcut); const [showEditDialog, setShowEditDialog] = useState(false); const shortcuts = collection.shortcutIds .map((shortcutId) => shortcutList.find((shortcut) => shortcut?.id === shortcutId)) .filter(Boolean) as any as Shortcut[]; + const showAdminActions = currentUser.id === collection.creatorId; const handleCopyCollectionLink = () => { copy(absolutifyLink(`/c/${collection.name}`)); @@ -65,29 +68,36 @@ const CollectionView = (props: Props) => {
- + - - - - - } - > + } + actionsClassName="!w-28 dark:text-gray-500" + actions={ + <> + + + + } + > + )}