-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Removed BIB file directory from search when preferences has option unchecked #6451
Conversation
Note to reviewers: We should really carefully think about that. Refs #459 (and linked PRs from there). |
Yes, I feel there is something amiss. Because when there is no directory selected in meta-data, user provided dir or BIB default directory, then the search directory list will be empty! |
We certainly need to check the documentation. Does it cover all cases discussed in the linked PR? Is the documetnation enough to serve as specification? JabRef has very powerful diretory features and we should be careful when touching that code. |
No, I have to look at the linked PR and check for all cases. I will get to it in a bit. Certainly, its not taken lightly. Will check for all cases. Its a WIP. |
So, if all three directories are empty (main file dir and the two in library properties and "Use bib file location as primary dir is checked" ) then it would return now an empty collection. And when I check the checkbox "Use bib file location" the bib file location is returned as first location. @silverhorse It would be nice if you add a test case for the Move Files Cleanup formatter which tests with all directories empty and the checkbox not checked. It should probably return false or does nothing |
@Siedlerchr yes will add a testcase for all dirs empty. Thanks! |
Tested with all combinations of the four options -
|
@koppor and @Siedlerchr plz review when you can. I have added some tests and done manual testing. Plz let me know if there are other scenarios I should test apart from one mentioned in msgs. |
// Due to mocking the externalFileType class, the file extension will not be found | ||
|
||
when(databaseContext.getFileDirectoriesAsPaths(any())).thenReturn(Collections.singletonList(path.getParent())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move the mockings here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mocking of getFileDirectoriesAsPaths method returns non empty values, which is not applicable for the newly added test case testFindAssociatedNotLinkedFilesForEmptySearchDir. The new test case expects that getFileDirectoriesAsPaths would return empty list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but the externalFileType should be independent of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, agreed. I will move that one back to setup.
…abref into fix-for-issue-5891
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's fine
Thanks for guidance and approval @Siedlerchr . Do you think more reviewers are needed for this change or is it good to merge? |
We have a strict rule in JabRef that each PR must be reviewed by at least two core developers before it can be merged with the master branch. Be patient. JabRef will still be there tomorrow and many other issues that need to be fixed. 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix. The changes look good to me.
Could you please change the text in the UI to clarify what this option does. "Use bib as primary" can be read differently depending on where to put the emphasize: on "use" (so either use it or not) or on "as primary" (so always use it, but not necessarily as first option). I think this was actually the origin of the whole misunderstanding.
Maybe something like "Search for files relative to library location".
I think the user documentation needs to be changed. Would be nice if you could see to this as well.
@tobiasdiez yes, I like your suggestion. It will remove any confusion regarding this option. Will make this change. |
@tobiasdiez I am working further to help @silverhorse, here is my change: I have question regarding localization, is there any step on how to get the translated text? or it should be automatic? I saw its recommended to use Crowdin but didn't find specific information on how the strings will be translated. can you please help out |
As a developer you don't have to worry about the actual translation. Simply use |
updated user documentation: JabRef/user-documentation#283 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good to me, I would adjust the wording a bit.
The file dir is not only used for searching but also for storing downloaded files (e.g. fulltext from fetcher downloads)
@@ -43,7 +43,7 @@ | |||
<TextField fx:id="mainFileDir" HBox.hgrow="ALWAYS"/> | |||
<Button onAction="#mainFileDirBrowse" text="%Browse"/> | |||
</HBox> | |||
<CheckBox fx:id="useBibLocationAsPrimary" text="%Use the BIB file location as primary file directory"> | |||
<CheckBox fx:id="useBibLocationAsPrimary" text="%Search for files relative to BIB file location"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<CheckBox fx:id="useBibLocationAsPrimary" text="%Search for files relative to BIB file location"> | |
<CheckBox fx:id="useBibLocationAsPrimary" text="%Search and store files relative to BIB file location"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe replace "bib file" with "library file" to be consistent with the more recent usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thanks for your contribution and the quick follow up! We hope you enjoyed contributing and we are looing forward for more PRs from you 🐱 |
Yay! Thanks @Siedlerchr and @tobiasdiez , appreciate your help! We are excited for our first OSS contribution! Thanks @abadar for last mile help. 🤩 |
ca943b70d7 Fix malformed XML in raptor-journal.csl (#6455) 2fad8d1104 Update knee-surgery-sports-traumatology-arthroscopy.csl (#6441) b4422b77b7 Update guide-des-citations-references-et-abreviations-juridiques.csl (#6450) cfe85da320 Create raptor-journal.csl (#6451) afbb963346 Create arkivoc.csl (#6134) 2f21ceb7b4 correct name disambiguation rules (#6442) 5b2191f38b Update bibliothek-forschung-und-praxis.csl (#6437) aaea3097d1 Update sodertorns-hogskola-oxford.csl (#6439) e4fbc605f8 Update universite-du-quebec-a-montreal.csl (#6438) 3653118f17 Small Fix to Bio-Protocol git-subtree-dir: buildres/csl/csl-styles git-subtree-split: ca943b70d73bd4c57c0b1266ee7c54907b8f9d4f
Fixes #5891
For "Automatically set file links" feature, the BIB file directory is always added for search, even though the checkbox is not clicked. If the checkbox is clicked, it is added at first position in list of directories to search, which is expected behaviour. However, it is still added to list of directories to search even when checkbox is left unselected, which is faulty. I fixed this by removing code which adds the directory when preference is set to false.
Also, changed the text of the file preferences in order to make it clear that files will be searched only when the checkbox "Search for files relative to BIB file location" is selected. Also changing user documentation to reflect this text change - JabRef/user-documentation#283
Before:
After: