✨(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
@@ -321,8 +321,20 @@ test.describe('Doc Tree', () => {
|
|||||||
'doc-child-emoji-child',
|
'doc-child-emoji-child',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update the emoji from the tree
|
|
||||||
const row = await getTreeRow(page, docChild);
|
const row = await getTreeRow(page, docChild);
|
||||||
|
|
||||||
|
// Check Remove emoji is not present initially
|
||||||
|
await row.hover();
|
||||||
|
const menu = row.getByText(`more_horiz`);
|
||||||
|
await menu.click();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('menuitem', { name: 'Remove emoji' }),
|
||||||
|
).toBeHidden();
|
||||||
|
|
||||||
|
// Close the menu
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
|
||||||
|
// Update the emoji from the tree
|
||||||
await row.locator('.--docs--doc-icon').click();
|
await row.locator('.--docs--doc-icon').click();
|
||||||
await page.getByRole('button', { name: '😀' }).first().click();
|
await page.getByRole('button', { name: '😀' }).first().click();
|
||||||
|
|
||||||
@@ -331,6 +343,16 @@ test.describe('Doc Tree', () => {
|
|||||||
await expect(
|
await expect(
|
||||||
page.getByRole('textbox', { name: 'Document title' }),
|
page.getByRole('textbox', { name: 'Document title' }),
|
||||||
).toContainText('😀');
|
).toContainText('😀');
|
||||||
|
|
||||||
|
// Now remove the emoji using the new action
|
||||||
|
await row.hover();
|
||||||
|
await menu.click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Remove emoji' }).click();
|
||||||
|
|
||||||
|
await expect(row.getByText('😀')).toBeHidden();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('textbox', { name: 'Document title' }),
|
||||||
|
).not.toContainText('😀');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import {
|
|||||||
Doc,
|
Doc,
|
||||||
ModalRemoveDoc,
|
ModalRemoveDoc,
|
||||||
Role,
|
Role,
|
||||||
|
getEmojiAndTitle,
|
||||||
useCopyDocLink,
|
useCopyDocLink,
|
||||||
useCreateChildDoc,
|
useCreateChildDoc,
|
||||||
|
useDocTitleUpdate,
|
||||||
useDuplicateDoc,
|
useDuplicateDoc,
|
||||||
} from '@/docs/doc-management';
|
} from '@/docs/doc-management';
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ export const DocTreeItemActions = ({
|
|||||||
const copyLink = useCopyDocLink(doc.id);
|
const copyLink = useCopyDocLink(doc.id);
|
||||||
const { mutate: detachDoc } = useDetachDoc();
|
const { mutate: detachDoc } = useDetachDoc();
|
||||||
const treeContext = useTreeContext<Doc | null>();
|
const treeContext = useTreeContext<Doc | null>();
|
||||||
|
|
||||||
const { mutate: duplicateDoc } = useDuplicateDoc({
|
const { mutate: duplicateDoc } = useDuplicateDoc({
|
||||||
onSuccess: (duplicatedDoc) => {
|
onSuccess: (duplicatedDoc) => {
|
||||||
// Reset the tree context root will reset the full tree view.
|
// 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 = () => {
|
const handleDetachDoc = () => {
|
||||||
if (!treeContext?.root) {
|
if (!treeContext?.root) {
|
||||||
return;
|
return;
|
||||||
@@ -82,6 +92,15 @@ export const DocTreeItemActions = ({
|
|||||||
},
|
},
|
||||||
...(!isRoot
|
...(!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'),
|
label: t('Move to my docs'),
|
||||||
isDisabled: doc.user_role !== Role.OWNER,
|
isDisabled: doc.user_role !== Role.OWNER,
|
||||||
|
|||||||
Reference in New Issue
Block a user