mirror of
https://github.com/usememos/memos.git
synced 2024-09-20 22:46:16 +08:00
chore: update tag rename
This commit is contained in:
parent
566171783d
commit
b9cbe6626f
|
@ -233,6 +233,7 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create resource").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create resource").SetInternal(err)
|
||||||
}
|
}
|
||||||
|
metric.Enqueue("resource create")
|
||||||
return c.JSON(http.StatusOK, convertResourceFromStore(resource))
|
return c.JSON(http.StatusOK, convertResourceFromStore(resource))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
|
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
|
||||||
|
"github.com/usememos/memos/server/service/metric"
|
||||||
"github.com/usememos/memos/store"
|
"github.com/usememos/memos/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to create resource: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to create resource: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metric.Enqueue("resource create")
|
||||||
return &apiv2pb.CreateResourceResponse{
|
return &apiv2pb.CreateResourceResponse{
|
||||||
Resource: s.convertResourceFromStore(ctx, resource),
|
Resource: s.convertResourceFromStore(ctx, resource),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -104,7 +104,7 @@ func (s *APIV2Service) RenameTag(ctx context.Context, request *apiv2pb.RenameTag
|
||||||
return nil, status.Errorf(codes.Internal, "failed to parse memo: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to parse memo: %v", err)
|
||||||
}
|
}
|
||||||
traverseASTNodes(nodes, func(node ast.Node) {
|
traverseASTNodes(nodes, func(node ast.Node) {
|
||||||
if tag, ok := node.(*ast.Tag); ok {
|
if tag, ok := node.(*ast.Tag); ok && tag.Content == request.OldName {
|
||||||
tag.Content = request.NewName
|
tag.Content = request.NewName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,8 +38,8 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
|
||||||
// Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
|
// Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
|
||||||
context.embeddedMemos.add(resourceName);
|
context.embeddedMemos.add(resourceName);
|
||||||
const params = new URLSearchParams(paramsStr);
|
const params = new URLSearchParams(paramsStr);
|
||||||
const useInlineMode = params.has("inline");
|
const inlineMode = params.has("inline");
|
||||||
if (useInlineMode) {
|
if (inlineMode) {
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<MemoContent nodes={memo.nodes} memoId={memo.id} embeddedMemos={context.embeddedMemos} />
|
<MemoContent nodes={memo.nodes} memoId={memo.id} embeddedMemos={context.embeddedMemos} />
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { toast } from "react-hot-toast";
|
||||||
import { tagServiceClient } from "@/grpcweb";
|
import { tagServiceClient } from "@/grpcweb";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
|
import { useFilterStore } from "@/store/module";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
@ -15,6 +16,7 @@ interface Props extends DialogProps {
|
||||||
const RenameTagDialog: React.FC<Props> = (props: Props) => {
|
const RenameTagDialog: React.FC<Props> = (props: Props) => {
|
||||||
const { tag, destroy } = props;
|
const { tag, destroy } = props;
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
|
const filterStore = useFilterStore();
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const [newName, setNewName] = useState(tag);
|
const [newName, setNewName] = useState(tag);
|
||||||
const requestState = useLoading(false);
|
const requestState = useLoading(false);
|
||||||
|
@ -24,8 +26,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
if (!newName) {
|
if (!newName || newName.includes(" ")) {
|
||||||
toast.error("Please fill all required fields");
|
toast.error("Tag name cannot be empty or contain spaces");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newName === tag) {
|
if (newName === tag) {
|
||||||
|
@ -40,13 +42,12 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
|
||||||
newName: newName,
|
newName: newName,
|
||||||
});
|
});
|
||||||
toast.success("Rename tag successfully");
|
toast.success("Rename tag successfully");
|
||||||
setTimeout(() => {
|
filterStore.setTagFilter(newName);
|
||||||
window.location.reload();
|
|
||||||
}, 300);
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error(error.details);
|
toast.error(error.details);
|
||||||
}
|
}
|
||||||
|
destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -75,9 +76,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<List className="!leading-5" size="sm" marker="disc">
|
<List className="!leading-5" size="sm" marker="disc">
|
||||||
<ListItem>All memes with this tag will be updated.</ListItem>
|
<ListItem>All your memos with this tag will be updated.</ListItem>
|
||||||
<ListItem>If the amount of data is large, it will take longer and the server load will become higher.</ListItem>
|
<ListItem>If the number of related memos is large, it will take longer and the server load will become higher.</ListItem>
|
||||||
<ListItem>The page will be automatically refreshed when the task is completed</ListItem>
|
|
||||||
</List>
|
</List>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-row justify-end items-center mt-2 space-x-2">
|
<div className="w-full flex flex-row justify-end items-center mt-2 space-x-2">
|
||||||
|
|
Loading…
Reference in a new issue