Blame · Line-by-line history
OpenPrAction.kt
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 0377886 | 1 | package com.gluecron.actions |
| 2 | ||
| 3 | import com.gluecron.GluecronUtil | |
| 4 | import com.gluecron.settings.GluecronSettingsState | |
| 5 | import com.intellij.notification.NotificationType | |
| 6 | import com.intellij.openapi.actionSystem.AnAction | |
| 7 | import com.intellij.openapi.actionSystem.AnActionEvent | |
| 8 | import com.intellij.openapi.project.DumbAware | |
| 9 | ||
| 10 | /** | |
| 11 | * Opens a browser tab showing the pull request list for the current repository. | |
| 12 | * | |
| 13 | * URL pattern: {host}/{owner}/{repo}/pulls | |
| 14 | * | |
| 15 | * This is the JetBrains equivalent of the VS Code "gluecron.openOnWeb" command | |
| 16 | * adapted for PR-centric workflow — surfacing the PR list rather than an | |
| 17 | * individual file, since JetBrains users primarily navigate via the IDE tree. | |
| 18 | */ | |
| 19 | class OpenPrAction : AnAction(), DumbAware { | |
| 20 | ||
| 21 | override fun actionPerformed(e: AnActionEvent) { | |
| 22 | val project = e.project ?: return | |
| 23 | val settings = GluecronSettingsState.getInstance() | |
| 24 | ||
| 25 | val (owner, repo) = GluecronUtil.detectOwnerRepo(project) | |
| 26 | ?: run { | |
| 27 | GluecronUtil.notify( | |
| 28 | project, | |
| 29 | "No Gluecron remote detected. Ensure the project has a git remote " + | |
| 30 | "pointing to ${settings.host}.", | |
| 31 | NotificationType.WARNING | |
| 32 | ) | |
| 33 | return | |
| 34 | } | |
| 35 | ||
| 36 | val url = "${settings.host}/$owner/$repo/pulls" | |
| 37 | GluecronUtil.openBrowser(url) | |
| 38 | } | |
| 39 | ||
| 40 | override fun update(e: AnActionEvent) { | |
| 41 | // Only enable when a project is open | |
| 42 | e.presentation.isEnabledAndVisible = e.project != null | |
| 43 | } | |
| 44 | } |