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

CLI: Toggle short ids and mv notebooks for #1728 #6671

Merged
merged 10 commits into from
Sep 5, 2022

Conversation

k33pn3xtlvl
Copy link
Contributor

I try to bundle all the works that has been done around the request #1728.

This is a summary of the events:

  1. Issue CLI: Add an option to mkbook command to the CLI client for creating sub notebooks. Fixes #1728 #3554 had a logical dependency from the issue Create subnotebooks in terminal #1728.
  2. This request (with a solution for #3554) was unfortunately not answered.
  3. Nearly a year later, the issue CLI: Fixes #1728 mv command works on notebooks now #5191 was try to solving the move-notebook problem, but was canceled.

Respect and thanks to @DominicLavery and @kai11 for their work!

The currently solution looks like this.

Method 1:

Work fine with notebook names mv folder1 folder2. As it was described in #5191.
If the user try to move the notebook (folder) with mv folder1 folder3 an error message appears, because there is an ambiguity. See Screenshot.

2022-07-16-05-59-40

Method 2:

If the title of the notebook is the same you must work with ids.
You press in the joplin cli ti for toggle ids an work with the short ids and use mv for example mv d82ed 419a0.


If this PR is merged we can go forward with create subnotebooks implementation #1728 .
A good suggestion came from @DominicLavery (#3554).

Again all credit goes to @DominicLavery and @kai11!

Based on the commit from
DominicLavery@6428e66
add to note list the same.
Need for issue laurent22#1728
Fix FolderListWidget view conflict
In my opinion the [solution](laurent22#5191 (comment))
works good. For the ambiguous notebooks you can use `toggle_ids` with `ti` and work with `mv`.

The credit goes to kai11 !
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator left a comment

Choose a reason for hiding this comment

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

Nice work so far! After reading through the diff, I have a few (all optional) suggestions. Feel free to ignore any/all of them!

A note about marking comments as resolved:

- **Do not mark your reviewer's comments as "resolved"**. If you do that, the comments will be hidden and the reviewer will not know what are the pending issues in the pull request. Only the reviewer should resolve the comments.

Feel free to ignore this part of CONTRIBUTING.md — I don't have the ability to mark the below comments as resolved.

packages/app-cli/app/command-mv.js Outdated Show resolved Hide resolved
packages/app-cli/app/command-mv.js Outdated Show resolved Hide resolved
packages/app-cli/app/command-mv.js Outdated Show resolved Hide resolved
packages/app-cli/app/command-mv.js Show resolved Hide resolved
Compliance with the style guide

Co-authored-by: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com>
@k33pn3xtlvl
Copy link
Contributor Author

@personalizedrefrigerator Thanks for your constructive suggestions for improvement.

Now i need someone who can approval this PR because from my site i see "1 workflow awaiting approval" (Need a maintainer to approve running workflow) or can i ignore this?

Please inform me if i need to do something additionally. (Maybe i have missed something).

@k33pn3xtlvl
Copy link
Contributor Author

Is it possible that the workflow sporadically does not run properly?
I have looked at the workflow logs and i can`t really figure it out where the error could be in relation to the PR.

@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Jul 26, 2022

Is it possible that the workflow sporadically does not run properly? I have looked at the workflow logs and i can`t really figure it out where the error could be in relation to the PR.

I think so. Pushing a new commit (e.g. merging in upstream/dev) should re-run the workflow!

@k33pn3xtlvl
Copy link
Contributor Author

Sorry for my questions i am new on the Project honestly, but can we merge this PR?
I need this merge to move on with the main goal of the #1728. I would keep merge requests small as possible.

Is something still need from my side? (Awaiting for approval, again)

image

@k33pn3xtlvl
Copy link
Contributor Author

@personalizedrefrigerator can you run the workflow again please.
The CI crashes on https://github.com/laurent22/joplin/runs/7575110850?check_suite_focus=true#step:10:4531 and it was fixed in 12a510c

@roman-r-m
Copy link
Collaborator

Strange. I thought I had approved it earlier today but it needs approval again. Approved now.

@k33pn3xtlvl
Copy link
Contributor Author

Ok, now it maybe my fault. I saw that the PR is still open after the checks have passed successfully. I try to click the button "update" an some one need to approval the workflow again.

I don't really understand by what criterion the PR are merged and by whom. I thought the merge is done if the the workflow process are successful.

Do I understand it correctly that no more actions are necessary from my side even if the workflow has passed all checks?

Optional recommendation. It would be helpful for new people (like me), if the merge process is described in the CONTRIBUTING.md. (Maybe it's an unwritten law and i do not know it) Feel free to ignore it if its so!

@personalizedrefrigerator
Copy link
Collaborator

Ok, now it maybe my fault. I saw that the PR is still open after the checks have passed successfully. I try to click the button "update" an some one need to approval the workflow again.

I don't really understand by what criterion the PR are merged and by whom. I thought the merge is done if the the workflow process are successful.

Do I understand it correctly that no more actions are necessary from my side even if the workflow has passed all checks?

Optional recommendation. It would be helpful for new people (like me), if the merge process is described in the CONTRIBUTING.md. (Maybe it's an unwritten law and i do not know it) Feel free to ignore it if its so!

I don't have permission to merge pull requests or grant access to run the automated tests. Code reviews/checks by maintainers are usually done about once every week. If everything looks good when that's done the pull request is generally merged.

@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Jul 30, 2022

I need this merge to move on with the main goal of the #1728. I would keep merge requests small as possible.

If you're willing to resolve future merge conflicts, you can open a second PR that includes the changes from this one!

It can be somewhat difficult to resolve merge conflicts and keep things consistent across branches, though. I generally have one or two development branches. I try to make changes to these branches first, then copy/backport individual changes to a new PR.

@k33pn3xtlvl
Copy link
Contributor Author

@laurent22 Can you merge it or is anything from my side to do?
People can test the pre-release maybe they will found some good improve ideas.

@@ -375,6 +375,11 @@ class AppGui {
this.showNoteMetadata(!this.widget('noteMetadata').shown);
}

toggleNotebookIds() {
Copy link
Owner

Choose a reason for hiding this comment

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

In code, always use "folder", not "notebook".


const notes = await app().loadItems(BaseModel.TYPE_NOTE, pattern);
if (!notes.length) throw new Error(_('Cannot find "%s".', pattern));
const dstDups = await Folder.search({ titlePattern: destination, limit: 2 });
Copy link
Owner

Choose a reason for hiding this comment

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

We avoid excessive abbreviations. So at least "destDuplicates"

if (!notes.length) throw new Error(_('Cannot find "%s".', pattern));
const dstDups = await Folder.search({ titlePattern: destination, limit: 2 });
if (dstDups.length > 1) {
throw new Error(_('Ambiguous notebook "%s". Please use notebook id instead - look for parent id in metadata', destination));
Copy link
Owner

Choose a reason for hiding this comment

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

I don't understand what this mean "look for parent id in metadata". What concrete action should the user do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, i updated it, it should be clearer now.

await Note.moveToFolder(notes[i].id, folder.id);
const itemFolder = await app().loadItem(BaseModel.TYPE_FOLDER, pattern);
if (itemFolder) {
const srcDups = await Folder.search({ titlePattern: pattern, limit: 2 });
Copy link
Owner

Choose a reason for hiding this comment

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

sourceDuplicates

if (itemFolder) {
const srcDups = await Folder.search({ titlePattern: pattern, limit: 2 });
if (srcDups.length > 1) {
throw new Error(_('Ambiguous notebook "%s". Please use notebook id instead - look for parent id in metadata or use $b for current', pattern));
Copy link
Owner

Choose a reason for hiding this comment

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

Same here

@Daeraxa Daeraxa added the cli CLI app specific issue label Sep 3, 2022
@laurent22 laurent22 merged commit b5b281c into laurent22:dev Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli CLI app specific issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants