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

Fixed Grobid Preference Dialog Logic, Removed Checkbox #12034

Merged
merged 13 commits into from
Oct 27, 2024

Conversation

arshchawla21
Copy link
Contributor

This issue revolves around the Grobid preference dialog logic. More specifically, it was found the "Do not ask again" button would not function as expected in certain cases, when asking the user for permission to use Grobid when uploading a PDF. Below demonstrates a logic diagram for the previous (broken) functionality. For context, the previous implentation (in GrobidPreferences.java), contained two boolean key variables, grobidEnabled and grobidOptOut.

controlFlowJabRef

From the diagram it is clear that in certain cases (highlighted red), the logic does not work as expected. A potential fix revolves around removing the checkbox altogether, only displaying the dialog once, and saving the users' preference for the future. This approach has been suggested by the following comments: #9801 (comment) and #9802 (comment). The new logic would operate as per the following diagram:

newFlow

My implementation follows the above logic, with grobidOptOut being redefined to grobidPreference. Below is the dialog a user will receive if they have not used Grobid before:

Screenshot 2024-10-20 102332

While this will work as expected for new users, one potential flaw is that some users (who have used Grobid in the past) will be also receive this dialog. Specifically users who had Grobid enabled and users who had Grobid disabled, but did not specifically opt-out (did not press "Do not ask again").

I believe the implementation is robust, but I'm always open to suggestions and would greatly appreciate any feedback on potential improvements!

Fixes JabRef#566.

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • 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.

arshchawla21 and others added 3 commits October 16, 2024 21:45
…D usage preference. "Do not ask" checkbox replaced with "Save Preference", and GROBID_OPTOUT replaced with GROBID_PREFERENCE to reduce ambiguity.
…only be asked about Grobid permissions once, with the preference being stored for the future. Updated CHANGELOG.md
CHANGELOG.md Outdated Show resolved Hide resolved
Localization.lang("Remote services"),
Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."),
Localization.lang("Do not ask again"),
optOut -> preferences.setGrobidOptOut(optOut));
Localization.lang("Yes"),
Copy link
Member

Choose a reason for hiding this comment

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

Yes no only dialogs should be avoided, as the buttons are not self explanatory, better wording:

  • Send to Grobid
  • Do not send

Copy link
Member

Choose a reason for hiding this comment

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

We have this requirement at https://devdocs.jabref.org/code-howtos/ui-recommendations.html#name-your-buttons-for-the-actions, but need more text for explanation.

„yes“ is not an action.

@koppor
Copy link
Member

koppor commented Oct 20, 2024

Note this removes the possibility to ask everytime. #9291 (comment) – This is OK for me now!

@koppor
Copy link
Member

koppor commented Oct 20, 2024

The new logic would operate as per the following diagram:

I like diagrams. Thank you!

I do not get what „enabled“ means.

The diagram does not show what happens after restart of JabRef. The dialog should only appear lf user did Not decide yet.

@koppor koppor added the status: changes required Pull requests that are not yet complete label Oct 23, 2024
*
* @param dialogService the DialogService to use
* @return if the user enabled Grobid, either in the past or after being asked by the dialog.
*/
public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, GrobidPreferences preferences) {
if (preferences.isGrobidEnabled()) {
return true;
if (preferences.isGrobidPreference()) {
Copy link
Member

Choose a reason for hiding this comment

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

We should use another word. This is NOT a JabRef setting (AKA preference), but a kind of "to prefer something". Moreover, this is asked at the first time only. Thus, I would rename it to isGrobidUseAsked. This is to strengthen that this is a one-time thing (in contrast to being asked at every run).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the observation, this would certainly make the logic more clear. I have made the changes as required.

@arshchawla21
Copy link
Contributor Author

Yes no only dialogs should be avoided, as the buttons are not self explanatory, better wording:

  • Send to Grobid
  • Do not send

I have updated the dialog as per this suggestion, improving clarity.

Screenshot 2024-10-27 085408

The new logic would operate as per the following diagram:

I like diagrams. Thank you!

I do not get what „enabled“ means.

The diagram does not show what happens after restart of JabRef. The dialog should only appear lf user did Not decide yet.

Enabled is referring to the grobidEnabled variable. To confirm, the dialog only appears if the user has not decided. This is due to the groidPreference variable being updated and stored after the user has made their decision for the first time.

…ity. Renamed GrobidPreferenceDialogHelper.java to GrobidUseDialogHelper.java.
@koppor
Copy link
Member

koppor commented Oct 26, 2024

@arshchawla21 I review using https://github.com/JabRef/jabref/pull/12034/files. Maybe, you should open this, too. - You will see that Christoph made a suggestion to the CHANGELOG.md

image

@koppor
Copy link
Member

koppor commented Oct 26, 2024

I resolved the merge conflicts in CHANGELOG.md to have the CI working.

Co-authored-by: Christoph <[email protected]>
koppor
koppor previously approved these changes Oct 27, 2024
@koppor koppor enabled auto-merge October 27, 2024 00:15
@koppor
Copy link
Member

koppor commented Oct 27, 2024

I added it to the merge queue. Should be in main in 30 minutes. Thank you for your work.

@arshchawla21
Copy link
Contributor Author

Thank you so much for your guidance @koppor, is there anything else I need to do? The unit test check appears to be failing.

@koppor
Copy link
Member

koppor commented Oct 27, 2024

Thank you so much for your guidance @koppor, is there anything else I need to do? The unit test check appears to be failing.

Fortunately, we have the merge queue doing the final checks properly.

Please check and fix:

 org.jabref.logic.l10n.LocalizationConsistencyTest

  Test findMissingLocalizationKeys() FAILED

  org.opentest4j.AssertionFailedError: 
  DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE
  PASTE THESE INTO THE ENGLISH LANGUAGE FILE "JabRef_en.properties"
  
  Do not send=Do not send
  Send to Grobid=Send to Grobid
  
   ==> expected: <[]> but was: <[Do not send (src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java LANG), Send to Grobid (src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java LANG)]>

auto-merge was automatically disabled October 27, 2024 01:33

Head branch was pushed to by a user without write access

koppor
koppor previously approved these changes Oct 27, 2024
@arshchawla21
Copy link
Contributor Author

Hi @koppor, I've made the required changes to "JabRef_en.properties", and the checks appear to be passing. I believe this PR is ready to merge whenever you are ready!

@koppor koppor added this pull request to the merge queue Oct 27, 2024
return false;
}
boolean grobidEnabled = dialogService.showConfirmationDialogWithOptOutAndWait(
boolean grobidEnabled = dialogService.showConfirmationDialogAndWait(
Copy link
Collaborator

Choose a reason for hiding this comment

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

The dialog should not be displayed if preferences are enabled without it. Here's an example:

  1. Reset preferences.
  2. Restart.
  3. Open preferences, then go to Web Search and allow Grobid.
  4. Import a file.
  5. The dialog will prompt to enable Grobid, even though it is already enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @LoayGhreeb, thanks for the suggestion. I have made changes such that if a user has manually enabled Grobid, they will not be prompted in any case (even if they manually disable Grobid in the future) as required.

@LoayGhreeb LoayGhreeb removed this pull request from the merge queue due to a manual request Oct 27, 2024
…le Grobid on first use, if Grobid has already been manually enabled.
LoayGhreeb
LoayGhreeb previously approved these changes Oct 27, 2024
@LoayGhreeb LoayGhreeb removed the status: changes required Pull requests that are not yet complete label Oct 27, 2024
@LoayGhreeb LoayGhreeb enabled auto-merge October 27, 2024 20:51
@LoayGhreeb LoayGhreeb added this pull request to the merge queue Oct 27, 2024
Merged via the queue into JabRef:main with commit ce27eb3 Oct 27, 2024
23 checks passed
@ThiloteE
Copy link
Member

@arshchawla21 If I may ask, what app did you use to make those diagrams?

@arshchawla21
Copy link
Contributor Author

arshchawla21 commented Nov 16, 2024

@arshchawla21 If I may ask, what app did you use to make those diagrams?

Of course, I used draw.io (available at https://app.diagrams.net/) to make the diagrams!

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.

Unchecked "Do not ask again" does not work
5 participants