mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update sidebar components
This commit is contained in:
@@ -51,22 +51,13 @@ func (s *APIV2Service) BatchUpsertTag(ctx context.Context, request *apiv2pb.Batc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV2Service) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) {
|
func (s *APIV2Service) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) {
|
||||||
|
tagFind := &store.FindTag{}
|
||||||
userID, err := ExtractUserIDFromName(request.User)
|
userID, err := ExtractUserIDFromName(request.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "invalid user name: %v", err)
|
return nil, status.Errorf(codes.InvalidArgument, "invalid user name: %v", err)
|
||||||
}
|
}
|
||||||
user, err := s.Store.GetUser(ctx, &store.FindUser{
|
tagFind.CreatorID = userID
|
||||||
ID: &userID,
|
tags, err := s.Store.ListTags(ctx, tagFind)
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
|
||||||
}
|
|
||||||
if user == nil {
|
|
||||||
return nil, status.Errorf(codes.NotFound, "user not found")
|
|
||||||
}
|
|
||||||
tags, err := s.Store.ListTags(ctx, &store.FindTag{
|
|
||||||
CreatorID: user.ID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to list tags: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to list tags: %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import SearchBar from "@/components/SearchBar";
|
import SearchBar from "@/components/SearchBar";
|
||||||
import UserList from "../UserList";
|
import UsersSection from "./UsersSection";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -15,7 +15,7 @@ const ExploreSidebar = (props: Props) => {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<SearchBar />
|
<SearchBar />
|
||||||
<UserList />
|
<UsersSection />
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -3,10 +3,10 @@ import { useEffect, useState } from "react";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useUserStore } from "@/store/v1";
|
import { useUserStore } from "@/store/v1";
|
||||||
import { User } from "@/types/proto/api/v2/user_service";
|
import { User } from "@/types/proto/api/v2/user_service";
|
||||||
import Icon from "./Icon";
|
import Icon from "../Icon";
|
||||||
import UserAvatar from "./UserAvatar";
|
import UserAvatar from "../UserAvatar";
|
||||||
|
|
||||||
const UserList = () => {
|
const UsersSection = () => {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const [users, setUsers] = useState<User[]>([]);
|
const [users, setUsers] = useState<User[]>([]);
|
||||||
|
|
||||||
@@ -48,4 +48,4 @@ const UserList = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UserList;
|
export default UsersSection;
|
@@ -1,8 +1,8 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import PersonalStatistics from "@/components/PersonalStatistics";
|
import PersonalStatistics from "@/components/PersonalStatistics";
|
||||||
import SearchBar from "@/components/SearchBar";
|
import SearchBar from "@/components/SearchBar";
|
||||||
import TagList from "@/components/TagList";
|
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
|
import TagsSection from "./TagsSection";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -20,7 +20,7 @@ const HomeSidebar = (props: Props) => {
|
|||||||
>
|
>
|
||||||
<SearchBar />
|
<SearchBar />
|
||||||
<PersonalStatistics user={currentUser} />
|
<PersonalStatistics user={currentUser} />
|
||||||
<TagList />
|
<TagsSection />
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -4,10 +4,10 @@ import useToggle from "react-use/lib/useToggle";
|
|||||||
import { useFilterStore, useTagStore } from "@/store/module";
|
import { useFilterStore, useTagStore } from "@/store/module";
|
||||||
import { useMemoList } from "@/store/v1";
|
import { useMemoList } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import showCreateTagDialog from "./CreateTagDialog";
|
import showCreateTagDialog from "../CreateTagDialog";
|
||||||
import { showCommonDialog } from "./Dialog/CommonDialog";
|
import { showCommonDialog } from "../Dialog/CommonDialog";
|
||||||
import Icon from "./Icon";
|
import Icon from "../Icon";
|
||||||
import showRenameTagDialog from "./RenameTagDialog";
|
import showRenameTagDialog from "../RenameTagDialog";
|
||||||
|
|
||||||
interface KVObject<T = any> {
|
interface KVObject<T = any> {
|
||||||
[key: string]: T;
|
[key: string]: T;
|
||||||
@@ -19,7 +19,7 @@ interface Tag {
|
|||||||
subTags: Tag[];
|
subTags: Tag[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const TagList = () => {
|
const TagsSection = () => {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const filterStore = useFilterStore();
|
const filterStore = useFilterStore();
|
||||||
const tagStore = useTagStore();
|
const tagStore = useTagStore();
|
||||||
@@ -195,4 +195,4 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TagList;
|
export default TagsSection;
|
@@ -1,6 +1,6 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import SearchBar from "./SearchBar";
|
import TagsSection from "../HomeSidebar/TagsSection";
|
||||||
import TagList from "./TagList";
|
import SearchBar from "../SearchBar";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -15,7 +15,7 @@ const TimelineSidebar = (props: Props) => {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<SearchBar />
|
<SearchBar />
|
||||||
<TagList />
|
<TagsSection />
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
};
|
};
|
@@ -1,7 +1,7 @@
|
|||||||
import { Drawer, IconButton } from "@mui/joy";
|
import { Drawer, IconButton } from "@mui/joy";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import Icon from "./Icon";
|
import Icon from "../Icon";
|
||||||
import TimelineSidebar from "./TimelineSidebar";
|
import TimelineSidebar from "./TimelineSidebar";
|
||||||
|
|
||||||
const TimelineSidebarDrawer = () => {
|
const TimelineSidebarDrawer = () => {
|
4
web/src/components/TimelineSidebar/index.ts
Normal file
4
web/src/components/TimelineSidebar/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import TimelineSidebar from "./TimelineSidebar";
|
||||||
|
import TimelineSidebarDrawer from "./TimelineSidebarDrawer";
|
||||||
|
|
||||||
|
export { TimelineSidebar, TimelineSidebarDrawer };
|
@@ -8,8 +8,7 @@ import showMemoEditorDialog from "@/components/MemoEditor/MemoEditorDialog";
|
|||||||
import MemoFilter from "@/components/MemoFilter";
|
import MemoFilter from "@/components/MemoFilter";
|
||||||
import MemoView from "@/components/MemoView";
|
import MemoView from "@/components/MemoView";
|
||||||
import MobileHeader from "@/components/MobileHeader";
|
import MobileHeader from "@/components/MobileHeader";
|
||||||
import TimelineSidebar from "@/components/TimelineSidebar";
|
import { TimelineSidebar, TimelineSidebarDrawer } from "@/components/TimelineSidebar";
|
||||||
import TimelineSidebarDrawer from "@/components/TimelineSidebarDrawer";
|
|
||||||
import { memoServiceClient } from "@/grpcweb";
|
import { memoServiceClient } from "@/grpcweb";
|
||||||
import { DAILY_TIMESTAMP, DEFAULT_LIST_MEMOS_PAGE_SIZE } from "@/helpers/consts";
|
import { DAILY_TIMESTAMP, DEFAULT_LIST_MEMOS_PAGE_SIZE } from "@/helpers/consts";
|
||||||
import { getNormalizedTimeString, getTimeStampByDate } from "@/helpers/datetime";
|
import { getNormalizedTimeString, getTimeStampByDate } from "@/helpers/datetime";
|
||||||
|
Reference in New Issue
Block a user