Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

feat: treeview component #421

Merged
merged 21 commits into from
Jan 11, 2024
Merged

feat: treeview component #421

merged 21 commits into from
Jan 11, 2024

Conversation

LinaYahya
Copy link
Contributor

@LinaYahya LinaYahya commented Nov 29, 2023

closes #413

@LinaYahya LinaYahya changed the title 413 navigation bar feat: treeview component Dec 1, 2023
@LinaYahya LinaYahya requested a review from pyphilia December 1, 2023 14:01
Copy link
Contributor

@pyphilia pyphilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! 🍃
So what do you do for the homepage? Is it using the old version? I don't remember.
I confused this PR with the builder's one, so maybe some comments are irrelevant but let me know.

cypress/e2e/navigation.cy.ts Outdated Show resolved Hide resolved
cypress/e2e/ws.cy.ts Outdated Show resolved Hide resolved
cypress/support/integrationUtils.ts Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/modules/tree/style.css Outdated Show resolved Hide resolved
src/modules/tree/DynamicTreeView.tsx Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
@LinaYahya LinaYahya self-assigned this Dec 15, 2023
@LinaYahya LinaYahya requested a review from pyphilia December 18, 2023 10:00
Copy link
Contributor

@pyphilia pyphilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work, I think it still need some refactor. Try to add more comments as well because it takes some time to understand why you're doing some things ☃️

src/modules/item/ItemNavigation.tsx Outdated Show resolved Hide resolved
src/modules/tree/TreeView.tsx Outdated Show resolved Hide resolved
src/modules/tree/TreeView.tsx Outdated Show resolved Hide resolved
src/modules/tree/TreeView.tsx Outdated Show resolved Hide resolved
src/modules/tree/TreeView.tsx Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
Comment on lines 174 to 176
if (data.length === 1) {
tree[data[0].id] = { ...data[0], children: [] };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need a special case for 1? Won't it work with the normal process?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically, we build our tree based on parent-children relation which will not work for a non-children Item, As we build a map tree based on parent

Comment on lines 178 to 186
const keys = Object.keys(mapTree);
const allChildren: string[] = keys.reduce((acc: string[], key: string) => {
const node = mapTree[key as keyof Tree];
if (node && node.children) {
acc.push(...node.children);
}
return acc;
}, []);
const rootKeys = keys.filter((key) => !allChildren.includes(key));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to find the rootKeys? I think for a normal player view you only have one root. Can't you define it in the arguments? Let's not take into account the home view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get the first parent, this is the only way to get it even it's only one root

Copy link
Contributor

@pyphilia pyphilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some issues:
Screenshot 2023-12-22 at 12 57 31
There is a random "show more" when I open any item.

There is a unwanted "flickering" when:

  • You click on a folder A. It expands as expected.
  • You click on another folder B. It expands as expected.
  • You click on A again, the folder folds. I think we should avoid this folding.
    My previous way of solving that was to only deal with expanding/folding using the arrow but no one liked it.
    Do you think it's possible to do something like:
  • click on folder A show and expands A.
  • click on folder B shows and expands B.
  • click on folder A again does not folds it but show it's content.
  • clicking on the arrow of A folds/expands it but does not show the content.

src/utils/item.ts Outdated Show resolved Hide resolved
Comment on lines 174 to 176
if (data.length === 1) {
tree[data[0].id] = { ...data[0], children: [] };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
src/utils/item.ts Outdated Show resolved Hide resolved
Copy link
Member

@spaenleh spaenleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proposed some changes in my commit to improve typings and also support the file mimetype icons.

I also tries to understand why the WS test was failing, see my explanation in the review. I add it here for visibility

The unexpected error that you get when you run these tests locally is due to vite using Websockets for hot module replacement (HMR).
In this test we stub the Websockets, so when vite tries to use them, it fails. The easiest way to get around this and keep the test is to not use the development server for this test, but to use a staticaly built version of the website served by a basic webserver.
I.e.: Do not launch the player for the interactive tests with yarn start:test but use the build + preview commands: yarn build --mode test && yarn preview --port 3333 the port should match what cypress expects.
This means you will not be able to change the source code interactively for these tests, but at least they will not fail because of stupid Websockets mocking issues. Hope it helps !

I removed unnecessary waits in tests.

cypress/e2e/main.cy.ts Outdated Show resolved Hide resolved
@@ -8,6 +8,8 @@ import {
import { FOLDER_WITH_SUBFOLDER_ITEM } from '../fixtures/items';
import { expectFolderButtonLayout } from '../support/integrationUtils';

Cypress.on('uncaught:exception', () => false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pyphilia @LinaYahya
The unexpected error that you get when you run these tests locally is due to vite using Websockets for hot module replacement (HMR).

In this test we stub the Websockets, so when vite tries to use them, it fails. The easiest way to get around this and keep the test is to not use the development server for this test, but to use a staticaly built version of the website served by a basic webserver.
I.e.: Do not launch the player for the interactive tests with yarn start:test but use the build + preview commands: yarn build --mode test && yarn preview --port 3333 the port should match what cypress expects.

This means you will not be able to change the source code interactively for these tests, but at least they will not fail because of stupid Websockets mocking issues. Hope it helps !

Comment on lines 103 to 105
cy.wait(100);
menu.click();
menu.get(`#${MAIN_MENU_ID}`).contains(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicking on the container is useless and results in not what is expected (opens the child that happens to be under it). I guess this was changed by @pyhpilia, maybe before the children were closed and clicking on the main menu was the only way to open it. Anyway in that case the chosen cypress selector should not have been MAIN_MENU as it will always be found (even when there is no data). Instead target something that is only present once data has been loaded (for example a selector with the item id of the root element).

@pyphilia pyphilia merged commit d6104ec into main Jan 11, 2024
2 checks passed
@pyphilia pyphilia deleted the 413-navigation-bar branch January 11, 2024 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change ui component in Sidebar (navigation bar) and data fetching
3 participants