[gig] Add an account menu to the welcome screen

GitOrigin-RevId: 0bc1bb8f74ab10f650c6dae1f3fafe8f379fb466
This commit is contained in:
Anna Rakhmukova
2025-04-14 21:34:13 +00:00
committed by intellij-monorepo-bot
parent 74cb188ae0
commit 5a3bc6504a
3 changed files with 22 additions and 4 deletions
@@ -105,6 +105,13 @@ object GHAccountsUtil {
fun createBrowserLoginAction(
model: GHLoginModel, project: Project, parentComponent: JComponent
): AnAction = DumbAwareAction.create(GithubBundle.message("action.Github.Accounts.AddGHAccount.text")) {
loginViaBrowser(model, project, parentComponent)
}
@ApiStatus.Internal
fun loginViaBrowser(
model: GHLoginModel, project: Project, parentComponent: JComponent?
) {
scopedDialog(project) {
GHLoginDialog.OAuth(model, project, this, parentComponent).apply {
setServer(GithubServerPath.DEFAULT_HOST, false)
@@ -114,8 +121,15 @@ object GHAccountsUtil {
@ApiStatus.Internal
fun createTokenLoginAction(
model: GHLoginModel, project: Project, parentComponent: JComponent
model: GHLoginModel, project: Project, parentComponent: JComponent,
): AnAction = DumbAwareAction.create(GithubBundle.message("action.Github.Accounts.AddGHAccountWithToken.text")) {
loginViaToken(model, project, parentComponent)
}
@ApiStatus.Internal
fun loginViaToken(
model: GHLoginModel, project: Project, parentComponent: JComponent?,
) {
scopedDialog(project) {
GHLoginDialog.Token(model, project, this, parentComponent).apply {
title = GithubBundle.message("dialog.title.add.github.account")
@@ -8,6 +8,7 @@ import com.intellij.collaboration.ui.ExceptionUtil
import com.intellij.openapi.components.service
import icons.CollaborationToolsIcons
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.plugins.github.api.GithubApiRequestExecutor
import org.jetbrains.plugins.github.api.GithubApiRequests
import org.jetbrains.plugins.github.api.data.GithubUserDetailed
@@ -18,7 +19,8 @@ import org.jetbrains.plugins.github.exceptions.GithubAuthenticationException
import org.jetbrains.plugins.github.util.CachingGHUserAvatarLoader
import java.awt.Image
internal class GHAccountsDetailsProvider(
@ApiStatus.Internal
class GHAccountsDetailsProvider(
scope: CoroutineScope,
private val executorSupplier: suspend (GithubAccount) -> GithubApiRequestExecutor?
) : LazyLoadingAccountsDetailsProvider<GithubAccount, GithubUserDetailed>(scope, CollaborationToolsIcons.Review.DefaultAvatar) {
@@ -9,6 +9,7 @@ import com.intellij.openapi.components.service
import icons.CollaborationToolsIcons
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.plugins.gitlab.GitLabServersManager
import org.jetbrains.plugins.gitlab.api.GitLabApi
import org.jetbrains.plugins.gitlab.api.dto.GitLabUserDTO
@@ -20,12 +21,13 @@ import org.jetbrains.plugins.gitlab.mergerequest.ui.toolwindow.GitLabSelectorErr
import org.jetbrains.plugins.gitlab.util.GitLabBundle
import java.awt.Image
internal class GitLabAccountsDetailsProvider private constructor(
@ApiStatus.Internal
class GitLabAccountsDetailsProvider private constructor(
scope: CoroutineScope,
private val apiClientSupplier: suspend (GitLabAccount) -> GitLabApi?
) : LazyLoadingAccountsDetailsProvider<GitLabAccount, GitLabUserDTO>(scope, CollaborationToolsIcons.Review.DefaultAvatar) {
constructor(
internal constructor(
scope: CoroutineScope,
accountsModel: GitLabAccountsListModel,
apiClientSupplier: suspend (GitLabAccount) -> GitLabApi?