Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Resolves #6167 : Move to notebook cannot distinguish notebooks with the same name #6400

Closed
wants to merge 22 commits into from

Conversation

bishoy-magdy
Copy link
Contributor

According to #6167, There are many ways to display the paths of folders.,I see the best way to show the path while preserving the search form is by adding the path title for each folder by using the label in the selector and adding a span with a title for each folder, Plus resetting the search by value only and I will get the path while traveling the folders in addOptions function.

And I fixed the bug that shows white space when there is no title on the folder in Move to notebook by adding an Untitled label.

Example:

demo.mp4

@laurent22
Copy link
Owner

It should show the full note path, including notebook on each line. Otherwise you indeed need something like a tooltip but nobody will know there's a tooltip, and it's not convenient if you have to move your mouse over each title.

@bishoy-magdy
Copy link
Contributor Author

It should show the full note path, including notebook on each line. Otherwise you indeed need something like a tooltip but nobody will know there's a tooltip, and it's not convenient if you have to move your mouse over each title.

Like this?
first second

I think in this case, we don't need indentDepth. We can use this space to display the path!

And searchByValue will compare only the notebook values (to search properly).

@laurent22
Copy link
Owner

I think it should display a tree, except when searching in which case it should disambiguate with the notebook name. I think that's what the original issue was suggesting.

@bishoy-magdy
Copy link
Contributor Author

I think it should display a tree, except when searching in which case it should disambiguate with the notebook name. I think that's what the original issue was suggesting.

I think you mean like this:

demo.mp4

and I used onInputChange to update the view.

if (folder.title === '') {
folder.title = 'Untitled';
}
const new_path = path + folder.title;
Copy link
Owner

Choose a reason for hiding this comment

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

newPath

options.startFolders = [];
});

it('Empty Notebook Title', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

"empty folder title"

});

it('Long Path', () => {
const testCases = [{ id: 1, title: '1', children: [{ id: 2, title: '2', children: [{ id: 3, title: '3', children: [{ id: 4, title: '4', children: [{ id: 5, title: '5', children: [{ id: 6, title: '6', children: [{ id: 7, title: '7', children: [{ id: 8, title: '8', children: [{ id: 9, title: '9', children: [{ id: 10, title: '10', children: [{ id: 11, title: '11', children: [{ id: 12, title: '12', children: [{ id: 13, title: '13', children: [{ id: 14, title: '14', children: [{ id: 15, title: '15' }] }] }] }] }] }] }] }] }] }] }] }] }] }, { id: 16, title: '16' }] }];
Copy link
Owner

Choose a reason for hiding this comment

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

Put that over multiple lines please. It's unreadable now

});

it('Diffrent Paths', () => {
const testCases = [{ id: 8, title: 'my Note' }, { id: 2, title: 'first', children: [{ id: 3, title: 'second', children: [{ id: 4, title: 'third', children: [{ id: 5, title: 'fourth' }] }, { id: 6, title: 'fourth' }] }, { id: 7, title: 'fourth' }] }];
Copy link
Owner

Choose a reason for hiding this comment

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

over multiple lines please


});

it('Diffrent Paths', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

different

const folder = folders[i];
// When NoteBook doesn't get a title
if (folder.title === '') {
folder.title = 'Untitled';
Copy link
Owner

Choose a reason for hiding this comment

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

What does it do if you leave it as an empty string? I'd prefer an empty string because untitled notebooks is not really something we support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does it do if you leave it as an empty string?

Any untitled notebook will appear in the search bar as an empty string like this:

untitled

What I did was just show the word 'Untitled' for any untitled notebook in the search.

Would you still prefer to remove this condition?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes please, remove it

return option._value;
};

const onInputChange = (_input) => {
Copy link
Owner

Choose a reason for hiding this comment

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

input

};

const onInputChange = (_input) => {
if (_input !== '') {
Copy link
Owner

Choose a reason for hiding this comment

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

if (input)

@laurent22
Copy link
Owner

Any update for this PR?

@bishoy-magdy
Copy link
Contributor Author

bishoy-magdy commented Jun 23, 2022

Any update for this PR?

Done :)
Sorry for the delay in updating the changes, and I did some refactoring of variables.

@@ -0,0 +1,106 @@
const moveToFolder = require('./moveToFolder');

Copy link
Owner

Choose a reason for hiding this comment

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

All new files should be TypeScript

Copy link
Owner

Choose a reason for hiding this comment

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

Also unfortunately I have no idea what these test units do. Have a look at what other test units do. For example the title is often it('should do this or that'). What does your code do? Explain it clearly in the test title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also unfortunately I have no idea what these test units do

It tests the AddOptions function that returns paths of folders with different scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have a look at what other test units do. For example the title is often it('should do this or that'). What does your code do? Explain it clearly in the test title.

OK, I will try to refactor the code and convert the unit test to TS.

export class AddOptions {

private maxDepth = 15;
public startFolders: any[] = [];
Copy link
Owner

Choose a reason for hiding this comment

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

FolderEntity. No "any" of you can avoid it

};

addOptions(folders, 0);
const options = new AddOptions();
Copy link
Owner

Choose a reason for hiding this comment

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

the naming is not good. Those are not options.

@laurent22
Copy link
Owner

Not sure what's the status of this PR?

@bishoy-magdy
Copy link
Contributor Author

Not sure what's the status of this PR?

When adding a new unit test (.test.ts) file in MainScreen/commands it crashes when building the Joplin app, and I see a unit test file automatically added in the index.ts file. Is there a solution to this problem? Or do I need to move a unit test file somewhere else?

yarn run watch log error:
gui/MainScreen/commands/index.ts:8:25 - error TS1005: 'from' expected.

8 import * as moveToFolder.test from './moveToFolder.test';
                          ~
gui/MainScreen/commands/index.ts:8:31 - error TS1005: ';' expected.
8 import * as moveToFolder.test from './moveToFolder.test';
                                ~~~~
gui/MainScreen/commands/index.ts:8:36 - error TS1005: ';' expected.
8 import * as moveToFolder.test from './moveToFolder.test';

error

@laurent22
Copy link
Owner

I believe this has been implemented in another pull request. Thanks anyway for looking into it @bishoy-magdy!

@laurent22 laurent22 closed this Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants