-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add option to clear recent libraries #10027
Conversation
As you may see I purposely let the unit test failing, as it is not clear to me why while setting three menu items:
the actual added items are in total two, excluding the |
Usually, we would have the view and view state in separate classes. That way we can test the view model which holds the state of the UI component. But in this case, FileHistoryMenu doesn't follow the MVVM pattern. We don't test the view because it is usually easy to validate, by just looking at it. We kind of assume that if the view model is in the correct state then the UI should reflect correctly. What I suggest is to expose the FileHistory object and test that. You can add the test to |
Certainly, it must not be considered. I just included that because it was unclear to me what causes the failure. |
@HoussemNasri Note : Failing test is not related to to the current code. |
void recentLibrariesAreCleared() { | ||
fileHistoryMenu.newFile(Path.of(BIBTEX_LIBRARY_PATH.concat("bibtexFiles/test.bib"))); | ||
|
||
fileHistoryMenu.clearRecentLibraries.getOnAction().handle(null); // retrieves the event handler |
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.
How about calling FileHistoryMenu#clearLIbrariesHistory directly? Doing so would make the transition to MVVM in the future easier because view models can't access views which in this case the button.
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.
Resolved
|
||
public void clearLibrariesHistory() { | ||
history.clear(); | ||
setDisable(true); |
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 would disable the button when recent libraries are empty, but I don't see any code that would re-enable it when recent library item is added.
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.
I assume that FileHistoryMenu#newFile(Path file)
invocation within the OpenDatabaseAction
class, will re-enable the item as the aforementioned method declares : setDisable(false)
. To my understanding, the menu Recent Libraries
shall be disabled unless the user opens a library.
I also tested it manually and the system's behavior is as expected. When we open a new library the Recent libraries
menu will be correctly enabled and the recent libraries will be listed.
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.
LGTM. Thanks for the contribution!
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.
Works here.
Other JabRef actions emit a notification of the successful execution. I missed that. However, I think, we should not increase the number of notifications, but more reduce them. Therefore, it is OK for me as is.
Resolves #10003
The current pull request serves as a new feature proposal, that provides the option to clear recent libraries' history. Essentially, a new menu item is included within the
File --> Recent Libraries
section that allows the user to erase any library previously opened.Step by Step
File
sectiona. Selects
Recent Libraries
menub. Clicks on
Clear Recent Libraries
optionRecent Libraries
menu will be disabled until the user opens a new library.About the implementation
FileHistoryMenu
class with the new menu item option, that serves the erasing of the recent libraries' history.FileHistoryMenuTest
class to validate the expected behavior of the operation.clear-recent-libraries-option.mov
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)