mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add delete tag action
This commit is contained in:
@@ -5,6 +5,7 @@ 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 Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
import showRenameTagDialog from "./RenameTagDialog";
|
import showRenameTagDialog from "./RenameTagDialog";
|
||||||
|
|
||||||
@@ -97,7 +98,9 @@ interface TagItemContainerProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContainerProps) => {
|
const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContainerProps) => {
|
||||||
|
const t = useTranslate();
|
||||||
const filterStore = useFilterStore();
|
const filterStore = useFilterStore();
|
||||||
|
const tagStore = useTagStore();
|
||||||
const { tag, tagQuery } = props;
|
const { tag, tagQuery } = props;
|
||||||
const isActive = tagQuery === tag.text;
|
const isActive = tagQuery === tag.text;
|
||||||
const hasSubTags = tag.subTags.length > 0;
|
const hasSubTags = tag.subTags.length > 0;
|
||||||
@@ -116,6 +119,18 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
|
|||||||
toggleSubTags();
|
toggleSubTags();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteTag = async () => {
|
||||||
|
showCommonDialog({
|
||||||
|
title: "Delete Tag",
|
||||||
|
content: "Are you sure to delete this tag?",
|
||||||
|
style: "danger",
|
||||||
|
dialogName: "delete-tag-dialog",
|
||||||
|
onConfirm: async () => {
|
||||||
|
await tagStore.deleteTag(tag.text);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="relative group flex flex-row justify-between items-center w-full h-8 py-0 mt-px first:mt-1 rounded-lg text-base sm:text-sm cursor-pointer select-none shrink-0 hover:opacity-80">
|
<div className="relative group flex flex-row justify-between items-center w-full h-8 py-0 mt-px first:mt-1 rounded-lg text-base sm:text-sm cursor-pointer select-none shrink-0 hover:opacity-80">
|
||||||
@@ -131,7 +146,10 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
|
|||||||
</div>
|
</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<Menu size="sm" placement="bottom-start">
|
<Menu size="sm" placement="bottom-start">
|
||||||
<MenuItem onClick={() => showRenameTagDialog({ tag: tag.text })}>Rename</MenuItem>
|
<MenuItem onClick={() => showRenameTagDialog({ tag: tag.text })}>{t("common.rename")}</MenuItem>
|
||||||
|
<MenuItem color="danger" onClick={handleDeleteTag}>
|
||||||
|
{t("common.delete")}
|
||||||
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<span className="truncate" onClick={handleTagClick}>
|
<span className="truncate" onClick={handleTagClick}>
|
||||||
|
Reference in New Issue
Block a user