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

Add a method to create a new file link manually #11539

Merged

Conversation

Kunal77689
Copy link
Contributor

@Kunal77689 Kunal77689 commented Jul 27, 2024

Closes #11017

Manual File Entry Creation:

  • Modified add button functionality so that rather than opening the file explorer, it opens a dialog box for manual file creation.

Screenshot 2024-07-27 004458
Screenshot 2024-07-27 004535
Screenshot 2024-07-27 004602

Mandatory checks

  • 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.

Manual File Entry Creation:
  Modified add button functionality so that rather than opening the file explorer, it opens a dialog box for manual file creation. [JabRef#11017]
@Kunal77689 Kunal77689 changed the title Manual file creation popup form kunalsikka dev Manual file creation popup form kunalsikka dev #11017 Jul 27, 2024
@Kunal77689 Kunal77689 changed the title Manual file creation popup form kunalsikka dev #11017 Added a method to create a new link manually #11017 Jul 27, 2024
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

The dialog code seems to be copied and slightly be adapted. Isn't it possible to adapt the existing code?

Code duplication leads to higher maintenance effort.

@Kunal77689
Copy link
Contributor Author

@koppor Sure I can give it a shot, thanks

- Deleted fxml and java files which were handling edit and add action separately and added a unified way which handles edit and add action dynamically
Comment on lines 36 to 38
public LinkedFileDialogController(LinkedFile linkedFile, boolean isEditMode) {
this.linkedFile = linkedFile != null ? linkedFile : new LinkedFile("", "", "");
this.isEditMode = isEditMode;
Copy link
Member

@subhramit subhramit Jul 27, 2024

Choose a reason for hiding this comment

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

Instead of making it so complicated, you can overload the constructor. One will take a LinkedFile for editing, another will not take any argument, for adding file. Invoke them accordingly.
This way, 1. you won't have to pass null values 2. won't need an additional isEditMode flag.

- Overloaded the constructor so that one will take a LinkedFile for editing, another will not take any argument.
@Kunal77689 Kunal77689 requested review from koppor and subhramit July 28, 2024 16:40
Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

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

Thank you for your changes. A few more suggestions.

CHANGELOG.md Outdated Show resolved Hide resolved
- Removed extra blank line in LinkedFilesEditorViewModel
-Added link to the pr in the CHANGELOG.md
@Kunal77689 Kunal77689 requested a review from subhramit July 31, 2024 22:13
Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

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

Good work so far. Now let's focus on the failing unit tests.

- Fixed findObsoleteLocalizationKeys() error by removing unwanted keys.
- Fixed findMissingLocalizationKeys() by adding "Add file link" as a key
@Kunal77689 Kunal77689 requested a review from subhramit July 31, 2024 23:06
Copy link
Member

@subhramit subhramit left a comment

Choose a reason for hiding this comment

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

Some comments on the renaming.
@koppor over to you now.

public class LinkedFileEditDialogView extends BaseDialog<LinkedFile> {
public class LinkedFileDialogController extends BaseDialog<LinkedFile> {
Copy link
Member

@subhramit subhramit Aug 1, 2024

Choose a reason for hiding this comment

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

This would be an architectural pattern shift. Read about what a model, view and controller is supposed to do, and also about the MVVM pattern followed in JabRef's JavaFX modules:
https://devdocs.jabref.org/code-howtos/javafx.html

@koppor is a controller needed here? the renaming seems off to me.

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK, we always call it "View". We have background material collected at https://devdocs.jabref.org/code-howtos/javafx.html#architecture-model---view---controller---viewmodel-mvcvm.

Please revert the change, afterwards, @calixtus should double check on this.

@JabRef JabRef deleted a comment from Kunal77689 Aug 1, 2024
@subhramit
Copy link
Member

subhramit commented Aug 1, 2024

@Kunal77689 meanwhile, you can update the PR description (learn about keywords like Closes, Fixes that reference issues, and write a description of your changes). Look at a few other PRs, how they are structured (nothing hard and fast, but for example the screenshots should be above the mandatory checks).

@subhramit subhramit changed the title Added a method to create a new link manually #11017 Add a method to create a new file link manually Aug 1, 2024
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Some code comments.

Moreover: general remarks

The hower of the "plus" button at General/File should show "Add", not open:

grafik


The howver of


The file type should be pre-filled with .pdf:

grafik


If possible, the fields should be prefilled with some "prompt text"

input.setPromptText(...);

Do you feel confident to lookup some matching strings in the localization file?


The two dialogs have different styles:

grafik

grafik

I think, some style loading is missing?

@@ -48,7 +49,7 @@
<ComboBox fx:id="fileType"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2"/>

<Label text="%Source URL" GridPane.rowIndex="3"/>
Copy link
Member

Choose a reason for hiding this comment

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

The % is an indication that this string should be looked up in the localization. Please keep it.

@@ -36,7 +37,7 @@
<JabRefIconView glyph="OPEN"/>
</graphic>
<tooltip>
<Tooltip text="%Browse"/>
Copy link
Member

Choose a reason for hiding this comment

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

The % is an indication that this string should be looked up in the localization. Please keep it.

</rowConstraints>

<Label text="%Link"/>
Copy link
Member

Choose a reason for hiding this comment

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

The % is an indication that this string should be looked up in the localization. Please keep it.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe, this is also an artifact that the string is put in the Java Code? Then use "" instead of some text.

public class LinkedFileEditDialogView extends BaseDialog<LinkedFile> {
public class LinkedFileDialogController extends BaseDialog<LinkedFile> {
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK, we always call it "View". We have background material collected at https://devdocs.jabref.org/code-howtos/javafx.html#architecture-model---view---controller---viewmodel-mvcvm.

Please revert the change, afterwards, @calixtus should double check on this.

@subhramit
Copy link
Member

Somehow some comments are getting duplicated. Strange.

viewModel.addNewFile();
LinkedFileDialogController controller = new LinkedFileDialogController();

controller.showAndWait().ifPresent(result -> {
Copy link
Member

Choose a reason for hiding this comment

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

You have to use org.jabref.gui.DialogService#showCustomDialogAndWait(javafx.scene.control.Dialog<R>) to get the right styling for the dialog.

- Renamed files from controller->view
- Made sure both edit and add dialog boxes follow   same layout
- The add dialog box will have pdf as the default   option
- fixed minor bugs in some places where some "%"    were removed in some of the previous commits,     restored those symbols
- on hover, rather than showing open, it will show add
@Kunal77689 Kunal77689 requested review from koppor and subhramit August 6, 2024 02:55

// Handle the result if the user clicked OK or Add
if (newLinkedFile != null) {
// Add the new file to your list or handle it as needed
Copy link
Member

Choose a reason for hiding this comment

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

Which AI assistant did you use? I want to learn about their capabiltiies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@koppor I generally use ChatGPT

@@ -18,7 +19,10 @@
import com.airhacks.afterburner.views.ViewLoader;
import jakarta.inject.Inject;

public class LinkedFileEditDialogView extends BaseDialog<LinkedFile> {
public class LinkedFileDialogView extends BaseDialog<LinkedFile> {
Copy link
Member

Choose a reason for hiding this comment

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

Please do not trust the AI in all cases.

The new name is not consistent to the name of the viewmodel

Copy link
Contributor Author

@Kunal77689 Kunal77689 Aug 6, 2024

Choose a reason for hiding this comment

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

@koppor My bad, I did not ask AI for the naming. I missed this link you provided above https://devdocs.jabref.org/code-howtos/javafx.html#architecture-model---view---controller---viewmodel-mvcvm, I just went on youtube and watched some videos about mvc structure and it mentioned about overall what model view and controller usually are responsible for so I thought because we are update the dialog box, it should come under view.

Copy link
Member

Choose a reason for hiding this comment

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

The thing is a Dialog. In other places in JabRef, dialogs also have the suffix Dialog. I renamed.

@koppor
Copy link
Member

koppor commented Aug 6, 2024

@Kunal77689 I took the liberty to finish this PR. I tried to do fine-grained commits to enable you to follow.

Our team invests significant time and resources, with a 2-to-1 ratio of senior developers mentoring each student. This approach is meant to help you grow your skills and deepen your understanding of coding and open-source contributions. I think, with the three reviewing rounds and this commits we fulfilled our duty.

@koppor koppor enabled auto-merge August 6, 2024 16:09
@Kunal77689
Copy link
Contributor Author

@koppor @subhramit Thank you so much for guidance throughout the task. This task helped me familiarize myself with parts of Jabref codebase which should help me in future contributions. I am looking forward to contributing more effectively in future

@koppor koppor added this pull request to the merge queue Aug 6, 2024
Merged via the queue into JabRef:main with commit 3c02efd Aug 6, 2024
22 checks passed
@subhramit
Copy link
Member

subhramit commented Dec 8, 2024

@Kunal77689 Hello Kunal. We noticed that under the "employees" heading of our LinkedIn page, you have stated yourself as being "self-employed" under the organization. Please note that you are not employed (by anyone or yourself) under the organization. You also claim to have "optimized user efficiency by over 50%", and we are completely unaware of the source from which you got the data, what metric you used, etc.

We kindly request you to take that down, as the PR you filed was not even completely your work, and the data is misleading. One AI generated PR does not count as an "experience", "project" or "employment".

@Kunal77689
Copy link
Contributor Author

Kunal77689 commented Dec 8, 2024 via email

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.

Add a method to create a new link manually
4 participants