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

Allow users to review backup changes before restoring them or merge them selectively #9311

Merged
merged 33 commits into from
Dec 5, 2022

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Oct 25, 2022

Closes #9066

Notes

The majority of the changed files are the result of changing terminology from 'ExternalChange' to 'DatabaseChange.' 'DatabseChange' now makes more sense because it can represent a change from a backup database too (rather than just external files).

Description

The goal of this feature is to prevent data loss in the event of a corrupted backup (see #9063). Users can review the changes that would happen to their database when they choose to restore the backup. Alternatively, they can selectively merge some of the changes from the backup database into their database.

Feature Workflow

  1. Review backup changes before restoring it
    a. User opens a library
    b. JabRef detects a difference between the library and the latest backup
    c. JabRef launches the restore backup dialog
    d. User selects Review backup to review backup changes
    e. User has done reviewing and chooses to close the Review backup dialog
    f. If the user approves the changes then he can select Restore from backup, otherwise he can select Ignore backup.
  2. Selectively merge backup
    a. User opens a library
    b. JabRef detects a difference between the library and the latest backup
    c. JabRef launches the restore backup dialog
    d. User selects Review backup to review backup changes
    e. User resolves the changes by selecting Accept or Deny for each change
    f. User resolved all changes and the dialog is closed
    g. JabRef applies the accepted changes to the current library

click-review-backup


image


2

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

HoussemNasri and others added 18 commits October 25, 2022 15:05
- This logic will be used for diffing backup and current library, so it make sense to move it from ChangeScanner to its own class.
* Included localization prefs in GeneralPreferences

* Convertet getLanguage to new prefs pattern

* Extracted localization from MetaDataDiff in logic

* Refactored FileHistory and converted getFileHistory to new prefs model

* Partial localization without restart

* Convert list to EnumSet

* Used pattern matching and applied IDE suggestions

* Fixed comparison of optionals
* Fix for issue #9157. Added method that capitalizes first letter of every word, including words after hyphens.

* Added test cases for CapitalizeFormatter
I was attempting to handle the dialog actions within the dialog class, but encountered some roadblocks. For example, when the user clicked restore from backup, I wanted to run the restore backup code without blocking the FX thread, so I wrapped it in a BackgroundTask#wrap. However, the database loading task in OpenDatabaseAction#loadDatabase will continue because the dialog is closed once the action is clicked, and the JVM continues running the code at BackupUIManager#showRestoreBackupDialog.
- An external change used to represent a database modification received from an external program. After this pr, an external change can also be a modification received from a backup library, and maybe later someone will use it to compare two libraries . For the above reasons, DatabaseChange is a better name.
- Because 'applyChanges' doesn't perform any IO operations or heavy computing, wrapping it in 'Platform.runLater' is unnecessary.
@HoussemNasri HoussemNasri changed the title Allow users to review backup before restoring it with selective merging Allow users to review backup changes before restoring them or merge them selectively Oct 25, 2022
@HoussemNasri HoussemNasri marked this pull request as ready for review October 31, 2022 14:17
@HoussemNasri
Copy link
Member Author

HoussemNasri commented Nov 1, 2022

Since JabRef saves 10 backup files, it would be nice to have a way choose the backup file (e.g. an older one) that should be restored and compared with status quo. Not sure if this goes beyond the scope of this pr though.

This is a great feature! However, I believe the 'Backup found' dialog is not the best place to access the feature. Thinking about it from the users' perspective, they would want to see their library as soon as possible. They may have lost one entry or all of them; they can't know (Maybe we should load the library before showing the dialog?). Browsing and comparing backups can take time, and it isn't necessary at that point because the backup libraries aren't going anywhere. At that point, it is preferable to have a simple UI with limited options. Once the library loads and they have done reviewing the damage, they can browse the backups and select the appropriate backup.

I really like the idea, but it is unfortunately out of scope. I would even argue that developing it would require more lines of code than this PR. This would make an excellent university project, in my opinion. I'll open an issue for it. I created a feature request: https://discourse.jabref.org/t/users-should-be-able-to-browse-and-merge-older-backups/3607

@koppor
Copy link
Member

koppor commented Nov 7, 2022

New dialog:

grafik

We discussed, it would be maybe good to use a text without any filename.

"A backup file was found. This could indicate that JabRef ..."

Then an additional button "Open backup folder". There, the backupped file should be highlighted.

(Would that be possible with low effort?)

@HoussemNasri
Copy link
Member Author

Then an additional button "Open backup folder". There, the backupped file should be highlighted.

I don't believe it's the best place to have the open backup folder feature. Perhaps we should include an 'Open backup folder' and an 'Open application data folder' button in the about dialog.

@HoussemNasri
Copy link
Member Author

In addition, we can make the backup file name a hyperlink, when it's clicked it opens the backup folder and selects the latest backup.

@calixtus
Copy link
Member

calixtus commented Nov 8, 2022

In addition, we can make the backup file name a hyperlink, when it's clicked it opens the backup folder and selects the latest backup.

Sounds somewhat nice, but does it fit in our current design pattern? Or should it be a button?

@HoussemNasri
Copy link
Member Author

@calixtus Four buttons/options seem excessive and overwhelming for one dialog. I don't recall seeing hyperlinks for opening folders in JabRef, so this could be a new pattern. If we can have a non-blocking dialog like the one shown below from Adobe PDF Reader, users will be able to access their backups from the about dialog if they wanted to.

Autosave Feature in Adobe Screen 2

@HoussemNasri
Copy link
Member Author

Please don't merge yet. I recently discovered a bug in which manually merging backup changes using the three-way merge does not work. However, clicking 'Accept' seems to work.

image

…e dialog

- In line 98, calling getVisibleChanges().remove(oldChange) might trigger the accepted changes to be applied and the dialog to close, thus, any change marked as accepted after that line will not be applied.
# Conflicts:
#	src/main/resources/l10n/JabRef_en.properties
# Conflicts:
#	src/main/java/org/jabref/gui/collab/ChangeScanner.java
#	src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java
#	src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java
@HoussemNasri HoussemNasri added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Dec 3, 2022
Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

At a first glance looks good. Will test it and take a other look tomorrow

@@ -256,7 +255,7 @@
}

.unchanged {
-rtfx-background-color:#0000;
-rtfx-background-color: #0000;
Copy link
Member

Choose a reason for hiding this comment

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

Extract that to a color constant?

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

Tested locally and works fine.! Hyperlink is cool feature!

@calixtus calixtus merged commit e86839a into main Dec 5, 2022
@calixtus calixtus deleted the merge-backup-manually branch December 5, 2022 19:17
Siedlerchr added a commit to MaryJml/jabref that referenced this pull request Dec 13, 2022
* upstream/main: (37 commits)
  Update database context in state manager after loading (JabRef#9450)
  Bump classgraph from 4.8.151 to 4.8.152 (JabRef#9448)
  Bump appleboy/ssh-action from 0.1.5 to 0.1.6 (JabRef#9443)
  Bump Pendect/action-rsyncer from 1.1.0 to 2.0.0 (JabRef#9444)
  Bump jackson-dataformat-yaml from 2.14.0 to 2.14.1 (JabRef#9445)
  Bump unirest-java from 3.14.0 to 3.14.1 (JabRef#9447)
  Bump postgresql from 42.5.0 to 42.5.1 (JabRef#9446)
  New Crowdin updates (JabRef#9435)
  Return absolute path in case an absolute one is given (JabRef#9433)
  New Crowdin updates (JabRef#9434)
  Fix for issue: right click menu 6601 (JabRef#9271)
  Fix modernizer and refactor protected terms (JabRef#9427)
  Observable Preferences (OpenOffice) (JabRef#9422)
  Allow users to review backup changes before restoring them or merge them selectively (JabRef#9311)
  Bump slf4j-api from 2.0.4 to 2.0.5 (JabRef#9428)
  Bump archunit-junit5-api from 1.0.0 to 1.0.1 (JabRef#9429)
  Bump jackson-datatype-jsr310 from 2.14.0 to 2.14.1 (JabRef#9430)
  Bump lucene-highlighter from 9.4.1 to 9.4.2 (JabRef#9431)
  Fix weird checkbox styling (JabRef#9425)
  New translations JabRef_en.properties (Italian) (JabRef#9424)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backup duplicateFinder status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When prompting for restoring the backup, a diff should be shown
6 participants