Skip to content

Commit

Permalink
fix: fix the folder selector filter behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
gnekoz authored May 23, 2023
1 parent 4f6c0d3 commit 424f989
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/ui-actions/move-conv-msg.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ const MoveConvMessage = ({
if (isRestore) {
return t('label.restore', 'Restore');
}
return t('folder_panel.modal.move.title_modal', 'Move Conversation');
return isMessageView
? t('folder_panel.modal.move.title_modal_message', 'Move Message')
: t('folder_panel.modal.move.title_modal_conversation', 'Move Conversation');
}
return t('folder_panel.modal.new.title', 'Create a new folder');
}, [isRestore, moveConvModal]);
}, [isMessageView, isRestore, moveConvModal]);

const footerConfirm = useMemo(() => {
if (moveConvModal) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/sidebar/commons/folder-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const FolderSelector = ({

result.push({
...item,
name: FOLDERS.USER_ROOT ? accountName : item.name,
name: item.id === FOLDERS.USER_ROOT ? accountName : item.name,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
CustomComponent: ModalAccordionCustomComponent,
Expand Down
61 changes: 61 additions & 0 deletions src/views/sidebar/commons/tests/folder-selector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React from 'react';
import { screen } from '@testing-library/react';
import { Folder, useFoldersByView } from '@zextras/carbonio-shell-ui';
import {
getFolder,
getFoldersArray,
getFoldersArrayByRoot,
getRootsArray,
Expand Down Expand Up @@ -66,4 +67,64 @@ describe('Folder selector', () => {
}
);
});

describe('Filter', () => {
test('if the user type "inbox" in the filter only the Inbox folder is displayed', async () => {
populateFoldersStore();

const props: FolderSelectorProps = {
folderId: FOLDERS.INBOX,
folderDestination: undefined,
setFolderDestination: jest.fn()
};
const { user } = setupTest(<FolderSelector {...props} />, { store });
const filterInput = screen.getByTestId('folder-name-filter');
await user.type(filterInput, 'inbox');
const accordionItems = screen.queryAllByTestId(/^folder-accordion-item-/);
expect(accordionItems.length).toBe(1);
expect(screen.getByTestId(`folder-accordion-item-${FOLDERS.INBOX}`)).toBeVisible();
});

test('if the user type "INBOX" in the filter only the Inbox folder is displayed', async () => {
populateFoldersStore();

const props: FolderSelectorProps = {
folderId: FOLDERS.INBOX,
folderDestination: undefined,
setFolderDestination: jest.fn()
};
const { user } = setupTest(<FolderSelector {...props} />, { store });
const filterInput = screen.getByTestId('folder-name-filter');
await user.type(filterInput, 'INBOX');
const accordionItems = screen.queryAllByTestId(/^folder-accordion-item-/);
expect(accordionItems.length).toBe(1);
expect(screen.getByTestId(`folder-accordion-item-${FOLDERS.INBOX}`)).toBeVisible();
});

test('if the user type an Inbox subfolder name in the filter that subfolder is displayed', async () => {
populateFoldersStore();

const inboxFolder = getFolder(FOLDERS.INBOX);
if (!inboxFolder) {
return;
}

const { children: inboxChildren } = inboxFolder;
if (!inboxChildren.length) {
return;
}

const inboxFirstChild = inboxChildren[0];

const props: FolderSelectorProps = {
folderId: FOLDERS.INBOX,
folderDestination: undefined,
setFolderDestination: jest.fn()
};
const { user } = setupTest(<FolderSelector {...props} />, { store });
const filterInput = screen.getByTestId('folder-name-filter');
await user.type(filterInput, inboxFirstChild.name);
expect(screen.getByTestId(`folder-accordion-item-${inboxFirstChild.id}`)).toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ const getFolderAbsPathParts = (folder: Folder): Array<string> => {
return matches[1].split('/');
};

const CustomBreadcrumbs = styled(Breadcrumbs)``;

const ModalAccordionCustomComponent: FC<{
item: Folder;
}> = ({ item }) => {
Expand Down
2 changes: 1 addition & 1 deletion translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@
"message1": "Einen Ordner als Ziel zum Verschieben aussuchen:",
"message2": "Wählen Sie einen Ordner für die Wiederherstellung aus:"
},
"title_modal": "Unterhaltung verschieben"
"title_modal_conversation": "Unterhaltung verschieben"
}
},
"action": {
Expand Down
4 changes: 3 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@
"message1": "Select a folder to move the considered one to:",
"message2": "Select a folder to restore to:"
},
"title_modal": "Move Conversation"
"title_modal": "Move Conversation",
"title_modal_conversation": "Move Conversation",
"title_modal_message": "Move Message"
},
"new": {
"create_footer": "Create and Move",
Expand Down
2 changes: 1 addition & 1 deletion translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
"message1": "Elige la carpeta hacia donde moverás la seleccionada:",
"message2": "Selecciona la carpeta en dónde quieres restaurar:"
},
"title_modal": "Selecciona la carpeta de destino"
"title_modal_conversation": "Selecciona la carpeta de destino"
},
"wipe": {
"body": {
Expand Down
2 changes: 1 addition & 1 deletion translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
},
"modal": {
"move": {
"title_modal": "Déplacer la Conversation",
"title_modal_conversation": "Déplacer la Conversation",
"body": {
"message1": "Sélectionnez un dossier dans lequel le déplacer :",
"message2": "Sélectionnez un dossier à restaurer dans :"
Expand Down
2 changes: 1 addition & 1 deletion translations/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"name_exist_warning": "नाम पहले से मौजूद है"
},
"move": {
"title_modal": "बात-चीत भेजें",
"title_modal_conversation": "बात-चीत भेजें",
"body": {
"message1": "चुने गए को भेजने के लिए कोई फोल्डर चुनें:",
"message2": "वापस ले जाने के लिए कोई फोल्डर चुनें:"
Expand Down
2 changes: 1 addition & 1 deletion translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
"name_exist_warning": "Nama sudah ada"
},
"move": {
"title_modal": "Pindahkan Percakapan",
"title_modal_conversation": "Pindahkan Percakapan",
"body": {
"message1": "Pilih satu folder sebagai tempat memindahkan file yang diinginkan:",
"message2": "Pilih folder sebagai tujuan pemulihan:"
Expand Down
2 changes: 1 addition & 1 deletion translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
}
},
"move": {
"title_modal": "Sposta Conversazione",
"title_modal_conversation": "Sposta Conversazione",
"body": {
"message1": "Seleziona una cartella in cui spostare quella selezionata:",
"message2": "Seleziona la cartella da ripristinare in:"
Expand Down
2 changes: 1 addition & 1 deletion translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@
}
},
"move": {
"title_modal": "会話を移動する",
"title_modal_conversation": "会話を移動する",
"body": {
"message1": "検討対象のフォルダを次の場所に移動するフォルダを選択します:",
"message2": "復元するフォルダを選択します:"
Expand Down
2 changes: 1 addition & 1 deletion translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@
"name_exist_warning": "Naam bestaat al"
},
"move": {
"title_modal": "Gesprek verplaatsen",
"title_modal_conversation": "Gesprek verplaatsen",
"body": {
"message1": "Selecteer een map om de overwogene naar te verplaatsen:",
"message2": "Selecteer een map om naar te herstellen:"
Expand Down
2 changes: 1 addition & 1 deletion translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
}
},
"move": {
"title_modal": "Przenieś Konwersację",
"title_modal_conversation": "Przenieś Konwersację",
"body": {
"message1": "Wybierz folder, do którego chcesz przenieść wybrany element:",
"message2": "Wybierz folder, do którego trafią przywrócone elementy:"
Expand Down
2 changes: 1 addition & 1 deletion translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@
"message1": "Selecione uma pasta onde mover a selecionada:",
"message2": "Selecione uma pasta para restaurar:"
},
"title_modal": "Selecione a pasta de destino"
"title_modal_conversation": "Selecione a pasta de destino"
},
"wipe": {
"body": {
Expand Down
2 changes: 1 addition & 1 deletion translations/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@
"message1": "Selecione uma pasta onde mover a selecionada:",
"message2": "Selecione uma pasta para restaurar:"
},
"title_modal": "Selecione a pasta de destino"
"title_modal_conversation": "Selecione a pasta de destino"
},
"wipe": {
"body": {
Expand Down
2 changes: 1 addition & 1 deletion translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
},
"modal": {
"move": {
"title_modal": "Перенести разговор",
"title_modal_conversation": "Перенести разговор",
"body": {
"message1": "Выберите папку, в которую нужно переместить эту:",
"message2": "Выберите папку для восстановления:"
Expand Down
2 changes: 1 addition & 1 deletion translations/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"message1": "เลือกโฟลเดอร์เพื่อย้ายไปที่:",
"message2": "เลือกโฟลเดอร์เพื่อกู้คืนไปที่:"
},
"title_modal": "ย้ายการสนทนา"
"title_modal_conversation": "ย้ายการสนทนา"
},
"wipe": {
"body": {
Expand Down
2 changes: 1 addition & 1 deletion translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@
"title": "Yeni klasör oluştur"
},
"move": {
"title_modal": "Görüşmeyi taşı",
"title_modal_conversation": "Görüşmeyi taşı",
"body": {
"message1": "İçine taşınmasını istediğiniz bir klasör seçin:",
"message2": "İçine geri yüklemek istediğiniz bir klasör seçin:"
Expand Down
2 changes: 1 addition & 1 deletion translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@
"message1": "Chọn một thư mục mà bạn cân nhắc:",
"message2": "Chọn một thư mục để khôi phục:"
},
"title_modal": "Di chuyển cuộc trò chuyện"
"title_modal_conversation": "Di chuyển cuộc trò chuyện"
},
"empty": {
"body": {
Expand Down
2 changes: 1 addition & 1 deletion translations/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
"message1": "选择文件夹以将其移动至:",
"message2": "选择要恢复至的文件夹:"
},
"title_modal": "移动会话"
"title_modal_conversation": "移动会话"
},
"new": {
"create_footer": "创建和移动",
Expand Down

0 comments on commit 424f989

Please sign in to comment.