Skip to content

Commit 192fa76

Browse files
olaurendeauAntoLC
authored andcommitted
✨(frontend) can remove emoji in the tree item actions
Add action button to remove emoji from a document title from the document tree.
1 parent b667200 commit 192fa76

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-tree.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,20 @@ test.describe('Doc Tree', () => {
321321
'doc-child-emoji-child',
322322
);
323323

324-
// Update the emoji from the tree
325324
const row = await getTreeRow(page, docChild);
325+
326+
// Check Remove emoji is not present initially
327+
await row.hover();
328+
const menu = row.getByText(`more_horiz`);
329+
await menu.click();
330+
await expect(
331+
page.getByRole('menuitem', { name: 'Remove emoji' }),
332+
).toBeHidden();
333+
334+
// Close the menu
335+
await page.keyboard.press('Escape');
336+
337+
// Update the emoji from the tree
326338
await row.locator('.--docs--doc-icon').click();
327339
await page.getByRole('button', { name: '😀' }).first().click();
328340

@@ -331,6 +343,16 @@ test.describe('Doc Tree', () => {
331343
await expect(
332344
page.getByRole('textbox', { name: 'Document title' }),
333345
).toContainText('😀');
346+
347+
// Now remove the emoji using the new action
348+
await row.hover();
349+
await menu.click();
350+
await page.getByRole('menuitem', { name: 'Remove emoji' }).click();
351+
352+
await expect(row.getByText('😀')).toBeHidden();
353+
await expect(
354+
page.getByRole('textbox', { name: 'Document title' }),
355+
).not.toContainText('😀');
334356
});
335357
});
336358

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import {
1313
Doc,
1414
ModalRemoveDoc,
1515
Role,
16+
getEmojiAndTitle,
1617
useCopyDocLink,
1718
useCreateChildDoc,
19+
useDocTitleUpdate,
1820
useDuplicateDoc,
1921
} from '@/docs/doc-management';
2022

@@ -44,6 +46,7 @@ export const DocTreeItemActions = ({
4446
const copyLink = useCopyDocLink(doc.id);
4547
const { mutate: detachDoc } = useDetachDoc();
4648
const treeContext = useTreeContext<Doc | null>();
49+
4750
const { mutate: duplicateDoc } = useDuplicateDoc({
4851
onSuccess: (duplicatedDoc) => {
4952
// Reset the tree context root will reset the full tree view.
@@ -52,6 +55,13 @@ export const DocTreeItemActions = ({
5255
},
5356
});
5457

58+
// Emoji Management
59+
const { emoji } = getEmojiAndTitle(doc.title ?? '');
60+
const { updateDocEmoji } = useDocTitleUpdate();
61+
const removeEmoji = () => {
62+
updateDocEmoji(doc.id, doc.title ?? '', '');
63+
};
64+
5565
const handleDetachDoc = () => {
5666
if (!treeContext?.root) {
5767
return;
@@ -82,6 +92,15 @@ export const DocTreeItemActions = ({
8292
},
8393
...(!isRoot
8494
? [
95+
...(emoji && doc.abilities.partial_update
96+
? [
97+
{
98+
label: t('Remove emoji'),
99+
icon: <Icon iconName="emoji_emotions" $size="24px" />,
100+
callback: removeEmoji,
101+
},
102+
]
103+
: []),
85104
{
86105
label: t('Move to my docs'),
87106
isDisabled: doc.user_role !== Role.OWNER,

0 commit comments

Comments
 (0)