✨(frontend) can remove emoji in the tree item actions
Add action button to remove emoji from a document title from the document tree.
This commit is contained in:
committed by
Anthony LC
parent
b667200ebd
commit
192fa76b54
@@ -13,8 +13,10 @@ import {
|
||||
Doc,
|
||||
ModalRemoveDoc,
|
||||
Role,
|
||||
getEmojiAndTitle,
|
||||
useCopyDocLink,
|
||||
useCreateChildDoc,
|
||||
useDocTitleUpdate,
|
||||
useDuplicateDoc,
|
||||
} from '@/docs/doc-management';
|
||||
|
||||
@@ -44,6 +46,7 @@ export const DocTreeItemActions = ({
|
||||
const copyLink = useCopyDocLink(doc.id);
|
||||
const { mutate: detachDoc } = useDetachDoc();
|
||||
const treeContext = useTreeContext<Doc | null>();
|
||||
|
||||
const { mutate: duplicateDoc } = useDuplicateDoc({
|
||||
onSuccess: (duplicatedDoc) => {
|
||||
// Reset the tree context root will reset the full tree view.
|
||||
@@ -52,6 +55,13 @@ export const DocTreeItemActions = ({
|
||||
},
|
||||
});
|
||||
|
||||
// Emoji Management
|
||||
const { emoji } = getEmojiAndTitle(doc.title ?? '');
|
||||
const { updateDocEmoji } = useDocTitleUpdate();
|
||||
const removeEmoji = () => {
|
||||
updateDocEmoji(doc.id, doc.title ?? '', '');
|
||||
};
|
||||
|
||||
const handleDetachDoc = () => {
|
||||
if (!treeContext?.root) {
|
||||
return;
|
||||
@@ -82,6 +92,15 @@ export const DocTreeItemActions = ({
|
||||
},
|
||||
...(!isRoot
|
||||
? [
|
||||
...(emoji && doc.abilities.partial_update
|
||||
? [
|
||||
{
|
||||
label: t('Remove emoji'),
|
||||
icon: <Icon iconName="emoji_emotions" $size="24px" />,
|
||||
callback: removeEmoji,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: t('Move to my docs'),
|
||||
isDisabled: doc.user_role !== Role.OWNER,
|
||||
|
||||
Reference in New Issue
Block a user