-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(git): add “Share to GitHub” flow #13677
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
Merged
koppor
merged 55 commits into
JabRef:main
from
wanling0000:feat/gsoc-git-share-to-github
Aug 18, 2025
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
2c1a9b5
feat(git): add “Share to GitHub” flow
wanling0000 755b84b
add module-info
wanling0000 9f4f675
Resolve conflicts
wanling0000 66d2e49
fix(git): add missing imports
wanling0000 79720ee
test: init repo in SlrGitHandlerTest; fix localization keys
wanling0000 f090c38
fix: fail fast on null/blank parameters
wanling0000 e880044
fix: Avoid silent failure in GitPreferences
wanling0000 667d317
refactor: avoid null init
wanling0000 a8cbdb9
Merge `upstream/main` into `feat/gsoc-git-share-to-github`
wanling0000 8864b63
add GitHandler class
wanling0000 1f0b3f6
fix: keep RuntimeException catch but using log WARN
wanling0000 cc01903
Test Stacked branch
wanling0000 0e3c9b1
fix: checkstyle error
wanling0000 16bc319
Merge `upstream/main` into `feat/gsoc-git-share-to-github`
wanling0000 609aae3
fix: add missing imports
wanling0000 cc55735
Use BackgroundTask and field Validator
wanling0000 d9cda75
Refactor GitPreferences align with ProxyPreferences
wanling0000 746eb72
Add https-only validator
wanling0000 2d05b88
Add TODOs and usage of StringUtil.isBlank
koppor afa356c
WIP - save intermediate GitPreferences refactor
wanling0000 8d2f3bc
WIP - save intermediate GitPreferences refactor
wanling0000 9f7e8f5
WIP
koppor 809cbe1
refactor: GitHub share dialog
wanling0000 0316c2b
Merge remote-tracking branch 'upstream/main' into clean/gsoc-git-shar…
wanling0000 1ec62d9
Compile fix
koppor 9b16562
Merge branch 'feat/gsoc-git-share-to-github' of github.com:wanling000…
koppor f3bf354
Convert GitPreferences to record (as suggested by IntelliJ)
koppor 1e0a344
Fix git PAT storage
wanling0000 984d9c4
Merge branch 'feat/gsoc-git-share-to-github' of github.com:wanling000…
wanling0000 dae0377
Add TODO note
koppor cf5d724
Merge branch 'feat/gsoc-git-share-to-github' of github.com:wanling000…
koppor 59adde0
Changes by subhr
koppor 5848b1a
Changes by fwl
koppor 8a137ac
Revert "Convert GitPreferences to record (as suggested by IntelliJ)"
koppor 12b5d74
Compile fix
koppor 4472d81
Disable non-working test
koppor 46cf427
Add ing to ADR-0016
koppor a4d667f
Rewrite Optional to ""
koppor 87353e1
Fix markdown lint
koppor 3f8a864
Link to ADR-0016
koppor 5a2ce1e
Fix casing
koppor 1af29d3
Fix architecture
koppor c49a1cf
Fix typo
koppor 01684be
Refine comments
koppor 3602e72
Remove TODO
koppor 160c398
More language cleanup
koppor 9ec8879
Fix empty line
koppor 752b7fe
Cleanup language again
koppor 614a0ff
Remove TODO
koppor 1f89a5a
Fix localization
koppor d7a2ff6
Remove separator
koppor 5ec253e
Git is first
koppor ed1ae89
Fix conversion
koppor 095f076
Use "notify" instead of a popup
koppor 2df3788
Remove obsolete string
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
jabgui/src/main/java/org/jabref/gui/git/GitShareToGitHubAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.jabref.gui.git; | ||
|
|
||
| import javafx.beans.binding.BooleanExpression; | ||
|
|
||
| import org.jabref.gui.DialogService; | ||
| import org.jabref.gui.StateManager; | ||
| import org.jabref.gui.actions.SimpleCommand; | ||
|
|
||
| import static org.jabref.gui.actions.ActionHelper.needsDatabase; | ||
|
|
||
| public class GitShareToGitHubAction extends SimpleCommand { | ||
InAnYan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final DialogService dialogService; | ||
| private final StateManager stateManager; | ||
|
|
||
| public GitShareToGitHubAction( | ||
| DialogService dialogService, | ||
| StateManager stateManager) { | ||
| this.dialogService = dialogService; | ||
| this.stateManager = stateManager; | ||
|
|
||
| this.executable.bind(this.enabledGitShare()); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| dialogService.showCustomDialogAndWait(new GitShareToGitHubDialogView()); | ||
| } | ||
|
|
||
| private BooleanExpression enabledGitShare() { | ||
| // TODO: Determine the correct condition for enabling "Git Share". This currently only requires an open library. | ||
koppor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // In the future, this may need to check whether: | ||
| // - the repo is initialized (because without a repository, the current implementation does not work -> future work) | ||
| // - etc. | ||
| // Can be called independent if a remote is configured or not -- it will be done in the dialog | ||
| // HowTo: Inject the observables (or maybe the stateManager) containing these constraints | ||
| return needsDatabase(stateManager); | ||
| } | ||
| } | ||
129 changes: 129 additions & 0 deletions
129
jabgui/src/main/java/org/jabref/gui/git/GitShareToGitHubDialogView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package org.jabref.gui.git; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.ButtonType; | ||
| import javafx.scene.control.CheckBox; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.control.PasswordField; | ||
| import javafx.scene.control.TextField; | ||
| import javafx.scene.control.Tooltip; | ||
|
|
||
| import org.jabref.gui.DialogService; | ||
| import org.jabref.gui.StateManager; | ||
| import org.jabref.gui.desktop.os.NativeDesktop; | ||
| import org.jabref.gui.preferences.GuiPreferences; | ||
| import org.jabref.gui.util.BaseDialog; | ||
| import org.jabref.gui.util.IconValidationDecorator; | ||
| import org.jabref.logic.l10n.Localization; | ||
| import org.jabref.logic.util.TaskExecutor; | ||
|
|
||
| import com.airhacks.afterburner.views.ViewLoader; | ||
| import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer; | ||
| import jakarta.inject.Inject; | ||
|
|
||
| public class GitShareToGitHubDialogView extends BaseDialog<Void> { | ||
| private static final String GITHUB_PAT_DOCS_URL = | ||
| "https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens"; | ||
|
|
||
| private static final String GITHUB_NEW_REPO_URL = "https://github.com/new"; | ||
|
|
||
| @FXML private TextField repositoryUrl; | ||
| @FXML private TextField username; | ||
| @FXML private PasswordField personalAccessToken; | ||
| @FXML private ButtonType shareButton; | ||
| @FXML private Label patHelpIcon; | ||
| @FXML private Tooltip patHelpTooltip; | ||
| @FXML private CheckBox rememberSettingsCheck; | ||
| @FXML private Label repoHelpIcon; | ||
| @FXML private Tooltip repoHelpTooltip; | ||
|
|
||
| private GitShareToGitHubDialogViewModel viewModel; | ||
|
|
||
| @Inject | ||
| private DialogService dialogService; | ||
|
|
||
| @Inject | ||
| private StateManager stateManager; | ||
|
|
||
| @Inject | ||
| private TaskExecutor taskExecutor; | ||
|
|
||
| @Inject | ||
| private GuiPreferences preferences; | ||
|
|
||
| private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer(); | ||
|
|
||
| public GitShareToGitHubDialogView() { | ||
| ViewLoader.view(this) | ||
| .load() | ||
| .setAsDialogPane(this); | ||
| } | ||
|
|
||
| @FXML | ||
| private void initialize() { | ||
| this.viewModel = new GitShareToGitHubDialogViewModel(preferences.getGitPreferences(), stateManager, dialogService, taskExecutor); | ||
|
|
||
| this.setTitle(Localization.lang("Share this Library to GitHub")); | ||
|
|
||
| // See "javafx.md" | ||
| this.setResultConverter(button -> { | ||
| if (button != ButtonType.CANCEL) { | ||
| // We do not want to use "OK", but we want to use a custom text instead. | ||
| // JavaFX does not allow to alter the text of the "OK" button. | ||
| // Therefore, we used another button type. | ||
| // Since we have only two buttons, we can check for non-cancel here. | ||
| shareToGitHub(); | ||
| } | ||
| return null; | ||
| }); | ||
|
|
||
| patHelpTooltip.setText( | ||
| Localization.lang("Click to open GitHub Personal Access Token documentation") | ||
| ); | ||
|
|
||
| username.setPromptText(Localization.lang("Your GitHub username")); | ||
| personalAccessToken.setPromptText(Localization.lang("PAT with repo access")); | ||
|
|
||
| repoHelpTooltip.setText( | ||
| Localization.lang("Create an empty repository on GitHub, then copy the HTTPS URL (ends with .git). Click to open GitHub.") | ||
| ); | ||
| Tooltip.install(repoHelpIcon, repoHelpTooltip); | ||
| repoHelpIcon.setOnMouseClicked(e -> | ||
| NativeDesktop.openBrowserShowPopup( | ||
| GITHUB_NEW_REPO_URL, | ||
| dialogService, | ||
| preferences.getExternalApplicationsPreferences() | ||
| ) | ||
| ); | ||
|
|
||
| Tooltip.install(patHelpIcon, patHelpTooltip); | ||
| patHelpIcon.setOnMouseClicked(e -> | ||
| NativeDesktop.openBrowserShowPopup( | ||
| GITHUB_PAT_DOCS_URL, | ||
| dialogService, | ||
| preferences.getExternalApplicationsPreferences() | ||
| ) | ||
| ); | ||
|
|
||
| repositoryUrl.textProperty().bindBidirectional(viewModel.repositoryUrlProperty()); | ||
| username.textProperty().bindBidirectional(viewModel.usernameProperty()); | ||
| personalAccessToken.textProperty().bindBidirectional(viewModel.patProperty()); | ||
| rememberSettingsCheck.selectedProperty().bindBidirectional(viewModel.rememberPatProperty()); | ||
|
|
||
| viewModel.setValues(); | ||
|
|
||
| Platform.runLater(() -> { | ||
| visualizer.setDecoration(new IconValidationDecorator()); | ||
|
|
||
| visualizer.initVisualization(viewModel.repositoryUrlValidation(), repositoryUrl, true); | ||
| visualizer.initVisualization(viewModel.githubUsernameValidation(), username, true); | ||
| visualizer.initVisualization(viewModel.githubPatValidation(), personalAccessToken, true); | ||
| }); | ||
| } | ||
|
|
||
| @FXML | ||
| private void shareToGitHub() { | ||
| viewModel.shareToGitHub(() -> this.close()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.