Skip to content

Commit 9bee24f

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: New translations jabref_en.properties (Italian) (#13725) Minor code style updates (#13722) Fix: Make FileUtil.relativize symlink-aware (#13553) New Crowdin updates (#13720) Bump org.glassfish.jersey.core:jersey-server in /versions (#13714) Enable UseObjectNotifyAll (#13718) Bump com.dlsc.gemsfx:gemsfx from 3.3.5 to 3.4.2 in /versions (#13717) Update on-issue-comment.yml Bump org.openrewrite.recipe:rewrite-recipe-bom from 3.12.1 to 3.13.0 (#13716) Bump org.openrewrite.rewrite from 7.12.1 to 7.14.0 (#13715) Bump org.glassfish.jersey.inject:jersey-hk2 in /versions (#13713) feat(git): add “Share to GitHub” flow (#13677) Bump jablib/src/main/resources/csl-styles from `292aec3` to `1194364` (#13712) Bump jablib/src/main/abbrv.jabref.org from `cfe719f` to `a97f9c6` (#13711) Bump jablib/src/main/resources/csl-locales from `e2de1e3` to `fa56de1` (#13710) Add noop Git Config System Reader to prevent usage of real world stuff into jgit (#13703) Added static (stream & preferences) constructors to BibDatabaseContext (#13694) New Crowdin updates (#13698) fix git modules requires and uses (#13696) Focus "Specify Bib(La)TeX" when Bib(La)TeX is in clipboard (#13633)
2 parents b6451f1 + 2f011eb commit 9bee24f

File tree

82 files changed

+1682
-429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1682
-429
lines changed

.github/workflows/on-issue-comment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
uses: takanome-dev/assign-issue-action@edge
1818
with:
1919
github_token: '${{ secrets.GITHUB_TOKEN }}'
20-
days_until_unassign: 14
20+
# If this is updated, also update the number at unassign-issues.yml
21+
days_until_unassign: 21
2122
maintainers: 'koppor,Siedlerchr,ThiloteE,calixtus,HoussemNasri,subhramit,InAnYan,LinusDietz'
2223
assigned_comment: |
2324
👋 Hey @{{ handle }}, thank you for your interest in this issue! 🎉

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
2727
- We added an initial [cite as you write](https://retorque.re/zotero-better-bibtex/citing/cayw/) endpoint. [#13187](https://github.com/JabRef/jabref/issues/13187)
2828
- We added "copy preview as markdown" feature. [#12552](https://github.com/JabRef/jabref/issues/12552)
2929
- In case no citation relation information can be fetched, we show the data providers reason. [#13549](https://github.com/JabRef/jabref/pull/13549)
30+
- When relativizing file names, symlinks are now taken into account. [#12995](https://github.com/JabRef/jabref/issues/12995)
3031
- We added a new button for shortening the DOI near the DOI field in the general tab when viewing an entry. [#13639](https://github.com/JabRef/jabref/issues/13639)
3132

3233
### Changed
@@ -73,10 +74,11 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
7374
- We introduced walkthrough functionality [#12664](https://github.com/JabRef/jabref/issues/12664)
7475

7576
### Fixed
76-
77+
78+
- We fixed an issue where "Specify Bib(La)TeX" tab was not focused when Bib(La)TeX was in the clipboard [#13597](https://github.com/JabRef/jabref/issues/13597)
7779
- We fixed an issue whereby the 'About' dialog was not honouring the user's configured font preferences. [#13558](https://github.com/JabRef/jabref/issues/13558)
7880
- We fixed an issue where the Pagetotal column was sorting the values alphabetically instead of numerically. [#12533](https://github.com/JabRef/jabref/issues/12533)
79-
- We fixed dark mode of BibTeX Source dialog in Citation Relations tab. [#13599](https://github.com/JabRef/jabref/issues/13599)
81+
- We fixed the dark mode of the BibTeX Source dialog in the Citation Relations tab. [#13599](https://github.com/JabRef/jabref/issues/13599)
8082
- We fixed an issue where the LibreOffice integration did not support citation keys containing Unicode characters. [#13301](https://github.com/JabRef/jabref/issues/13301)
8183
- We fixed an issue where the "Search ShortScience" action did not convert LaTeX-formatted titles to Unicode. [#13418](https://github.com/JabRef/jabref/issues/13418)
8284
- We fixed an issue where LaTeX file directories were not properly shared between different users on the same host. [#9990](https://github.com/JabRef/jabref/issues/9990)

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
plugins {
22
id("org.jabref.gradle.base.repositories")
33
id("org.jabref.gradle.feature.compile") // for openrewrite
4-
id("org.openrewrite.rewrite") version "7.12.1"
4+
id("org.openrewrite.rewrite") version "7.14.0"
55
id("org.itsallcode.openfasttrace") version "3.1.0"
66
}
77

88
// OpenRewrite should rewrite all sources
99
// This is the behavior when applied in the root project (https://docs.openrewrite.org/reference/gradle-plugin-configuration#multi-module-gradle-projects)
1010

1111
dependencies {
12-
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.12.1"))
12+
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.13.0"))
1313
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
1414
rewrite("org.openrewrite.recipe:rewrite-logging-frameworks")
1515
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks")

docs/decisions/0016-mutable-preferences-objects.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ To create an immutable preferences object every time seems to be a waste of time
1818
Chosen option: "Alter the exiting object", because the preferences objects are just wrappers around the basic preferences framework of JDK. They
1919
should be mutable on-the-fly similar to objects with a Builder inside and to be stored immediately again in the
2020
preferences.
21+
22+
### Consequences
23+
24+
* Import logic will be more hard as exising preferences objects have to be altered; and it is very hard to know which preference objects exactly are needed to be modified.
25+
* Cached variables need to be observables, too. AKA The cache needs to be observable.
26+
* There is NO "real" factory pattern for the preferences objects, as they are mutable --> they are passed via the constructor and long-lived

jabgui/src/main/java/org/jabref/gui/actions/StandardActions.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ public enum StandardActions implements Action {
217217
GROUP_SUBGROUP_RENAME(Localization.lang("Rename subgroup"), KeyBinding.GROUP_SUBGROUP_RENAME),
218218
GROUP_ENTRIES_REMOVE(Localization.lang("Remove selected entries from this group")),
219219

220-
CLEAR_EMBEDDINGS_CACHE(Localization.lang("Clear embeddings cache"));
220+
CLEAR_EMBEDDINGS_CACHE(Localization.lang("Clear embeddings cache")),
221+
222+
GIT(Localization.lang("Git"), IconTheme.JabRefIcons.GIT_SYNC),
223+
GIT_PULL(Localization.lang("Pull")),
224+
GIT_PUSH(Localization.lang("Push")),
225+
GIT_COMMIT(Localization.lang("Commit")),
226+
GIT_SHARE(Localization.lang("Share this library to GitHub"));
221227

222228
private String text;
223229
private final String description;

jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.jabref.gui.externalfiles.AutoLinkFilesAction;
4040
import org.jabref.gui.externalfiles.DownloadFullTextAction;
4141
import org.jabref.gui.externalfiles.FindUnlinkedFilesAction;
42+
import org.jabref.gui.git.GitShareToGitHubAction;
4243
import org.jabref.gui.help.AboutAction;
4344
import org.jabref.gui.help.ErrorConsoleAction;
4445
import org.jabref.gui.help.HelpAction;
@@ -180,10 +181,19 @@ private void createMenu() {
180181

181182
new SeparatorMenuItem(),
182183

184+
// region: Sharing of the library
185+
186+
// TODO: Should be only enabled if not yet shared.
187+
factory.createSubMenu(StandardActions.GIT,
188+
factory.createMenuItem(StandardActions.GIT_SHARE, new GitShareToGitHubAction(dialogService, stateManager))
189+
),
190+
183191
factory.createSubMenu(StandardActions.REMOTE_DB,
184192
factory.createMenuItem(StandardActions.CONNECT_TO_SHARED_DB, new ConnectToSharedDatabaseCommand(frame, dialogService)),
185193
factory.createMenuItem(StandardActions.PULL_CHANGES_FROM_SHARED_DB, new PullChangesFromSharedAction(stateManager))),
186194

195+
// endregion
196+
187197
new SeparatorMenuItem(),
188198

189199
factory.createMenuItem(StandardActions.SHOW_PREFS, new ShowPreferencesAction(frame, dialogService)),

jabgui/src/main/java/org/jabref/gui/git/GitPullViewModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public GitPullViewModel(GitSyncService syncService, GitStatusViewModel gitStatus
2525
public MergeResult pull() throws IOException, GitAPIException, JabRefException {
2626
Optional<BibDatabaseContext> databaseContextOpt = gitStatusViewModel.getDatabaseContext();
2727
if (databaseContextOpt.isEmpty()) {
28-
throw new JabRefException(Localization.lang("Cannot pull: No active BibDatabaseContext."));
28+
throw new JabRefException(Localization.lang("No library selected"));
2929
}
3030

3131
BibDatabaseContext localBibDatabaseContext = databaseContextOpt.get();
3232
Path bibFilePath = localBibDatabaseContext.getDatabasePath().orElseThrow(() ->
33-
new JabRefException(Localization.lang("Cannot pull: .bib file path missing in BibDatabaseContext."))
33+
new JabRefException(Localization.lang("Cannot pull: Please save the library to a file first."))
3434
);
3535

3636
MergeResult result = syncService.fetchAndMerge(localBibDatabaseContext, bibFilePath);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.jabref.gui.git;
2+
3+
import javafx.beans.binding.BooleanExpression;
4+
5+
import org.jabref.gui.DialogService;
6+
import org.jabref.gui.StateManager;
7+
import org.jabref.gui.actions.SimpleCommand;
8+
9+
import static org.jabref.gui.actions.ActionHelper.needsDatabase;
10+
11+
public class GitShareToGitHubAction extends SimpleCommand {
12+
private final DialogService dialogService;
13+
private final StateManager stateManager;
14+
15+
public GitShareToGitHubAction(
16+
DialogService dialogService,
17+
StateManager stateManager) {
18+
this.dialogService = dialogService;
19+
this.stateManager = stateManager;
20+
21+
this.executable.bind(this.enabledGitShare());
22+
}
23+
24+
@Override
25+
public void execute() {
26+
dialogService.showCustomDialogAndWait(new GitShareToGitHubDialogView());
27+
}
28+
29+
private BooleanExpression enabledGitShare() {
30+
// TODO: Determine the correct condition for enabling "Git Share". This currently only requires an open library.
31+
// In the future, this may need to check whether:
32+
// - the repo is initialized (because without a repository, the current implementation does not work -> future work)
33+
// - etc.
34+
// Can be called independent if a remote is configured or not -- it will be done in the dialog
35+
// HowTo: Inject the observables (or maybe the stateManager) containing these constraints
36+
return needsDatabase(stateManager);
37+
}
38+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package org.jabref.gui.git;
2+
3+
import javafx.application.Platform;
4+
import javafx.fxml.FXML;
5+
import javafx.scene.control.ButtonType;
6+
import javafx.scene.control.CheckBox;
7+
import javafx.scene.control.Label;
8+
import javafx.scene.control.PasswordField;
9+
import javafx.scene.control.TextField;
10+
import javafx.scene.control.Tooltip;
11+
12+
import org.jabref.gui.DialogService;
13+
import org.jabref.gui.StateManager;
14+
import org.jabref.gui.desktop.os.NativeDesktop;
15+
import org.jabref.gui.preferences.GuiPreferences;
16+
import org.jabref.gui.util.BaseDialog;
17+
import org.jabref.gui.util.IconValidationDecorator;
18+
import org.jabref.logic.l10n.Localization;
19+
import org.jabref.logic.util.TaskExecutor;
20+
21+
import com.airhacks.afterburner.views.ViewLoader;
22+
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
23+
import jakarta.inject.Inject;
24+
25+
public class GitShareToGitHubDialogView extends BaseDialog<Void> {
26+
private static final String GITHUB_PAT_DOCS_URL =
27+
"https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens";
28+
29+
private static final String GITHUB_NEW_REPO_URL = "https://github.com/new";
30+
31+
@FXML private TextField repositoryUrl;
32+
@FXML private TextField username;
33+
@FXML private PasswordField personalAccessToken;
34+
@FXML private ButtonType shareButton;
35+
@FXML private Label patHelpIcon;
36+
@FXML private Tooltip patHelpTooltip;
37+
@FXML private CheckBox rememberSettingsCheck;
38+
@FXML private Label repoHelpIcon;
39+
@FXML private Tooltip repoHelpTooltip;
40+
41+
private GitShareToGitHubDialogViewModel viewModel;
42+
43+
@Inject
44+
private DialogService dialogService;
45+
46+
@Inject
47+
private StateManager stateManager;
48+
49+
@Inject
50+
private TaskExecutor taskExecutor;
51+
52+
@Inject
53+
private GuiPreferences preferences;
54+
55+
private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer();
56+
57+
public GitShareToGitHubDialogView() {
58+
ViewLoader.view(this)
59+
.load()
60+
.setAsDialogPane(this);
61+
}
62+
63+
@FXML
64+
private void initialize() {
65+
this.viewModel = new GitShareToGitHubDialogViewModel(preferences.getGitPreferences(), stateManager, dialogService, taskExecutor);
66+
67+
this.setTitle(Localization.lang("Share this Library to GitHub"));
68+
69+
// See "javafx.md"
70+
this.setResultConverter(button -> {
71+
if (button != ButtonType.CANCEL) {
72+
// We do not want to use "OK", but we want to use a custom text instead.
73+
// JavaFX does not allow to alter the text of the "OK" button.
74+
// Therefore, we used another button type.
75+
// Since we have only two buttons, we can check for non-cancel here.
76+
shareToGitHub();
77+
}
78+
return null;
79+
});
80+
81+
patHelpTooltip.setText(
82+
Localization.lang("Click to open GitHub Personal Access Token documentation")
83+
);
84+
85+
username.setPromptText(Localization.lang("Your GitHub username"));
86+
personalAccessToken.setPromptText(Localization.lang("PAT with repo access"));
87+
88+
repoHelpTooltip.setText(
89+
Localization.lang("Create an empty repository on GitHub, then copy the HTTPS URL (ends with .git). Click to open GitHub.")
90+
);
91+
Tooltip.install(repoHelpIcon, repoHelpTooltip);
92+
repoHelpIcon.setOnMouseClicked(e ->
93+
NativeDesktop.openBrowserShowPopup(
94+
GITHUB_NEW_REPO_URL,
95+
dialogService,
96+
preferences.getExternalApplicationsPreferences()
97+
)
98+
);
99+
100+
Tooltip.install(patHelpIcon, patHelpTooltip);
101+
patHelpIcon.setOnMouseClicked(e ->
102+
NativeDesktop.openBrowserShowPopup(
103+
GITHUB_PAT_DOCS_URL,
104+
dialogService,
105+
preferences.getExternalApplicationsPreferences()
106+
)
107+
);
108+
109+
repositoryUrl.textProperty().bindBidirectional(viewModel.repositoryUrlProperty());
110+
username.textProperty().bindBidirectional(viewModel.usernameProperty());
111+
personalAccessToken.textProperty().bindBidirectional(viewModel.patProperty());
112+
rememberSettingsCheck.selectedProperty().bindBidirectional(viewModel.rememberPatProperty());
113+
114+
viewModel.setValues();
115+
116+
Platform.runLater(() -> {
117+
visualizer.setDecoration(new IconValidationDecorator());
118+
119+
visualizer.initVisualization(viewModel.repositoryUrlValidation(), repositoryUrl, true);
120+
visualizer.initVisualization(viewModel.githubUsernameValidation(), username, true);
121+
visualizer.initVisualization(viewModel.githubPatValidation(), personalAccessToken, true);
122+
});
123+
}
124+
125+
@FXML
126+
private void shareToGitHub() {
127+
viewModel.shareToGitHub(() -> this.close());
128+
}
129+
}

0 commit comments

Comments
 (0)