From ad0f158cf5e445ef4d54c92b41d0abe697da7757 Mon Sep 17 00:00:00 2001 From: Kodama Naoyuki Date: Tue, 28 Jan 2025 22:21:49 +0900 Subject: [PATCH 1/2] feat: add Git repository fetching workflow --- .../application/GitProviderWorkflow.kt | 14 ++++++++++++++ .../application/dto/GitRepositoryDto.kt | 3 +++ .../domain/GitProviderService.kt | 19 +++++++++++++++++++ .../domain/model/GitRepository.kt | 3 +++ 4 files changed, 39 insertions(+) create mode 100644 src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/GitProviderWorkflow.kt create mode 100644 src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/dto/GitRepositoryDto.kt create mode 100644 src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/GitProviderService.kt create mode 100644 src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/model/GitRepository.kt diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/GitProviderWorkflow.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/GitProviderWorkflow.kt new file mode 100644 index 00000000..dca98b93 --- /dev/null +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/GitProviderWorkflow.kt @@ -0,0 +1,14 @@ +package com.github.naoyukik.intellijplugingithubnotifications.application + +import com.github.naoyukik.intellijplugingithubnotifications.application.dto.GitRepositoryDto +import com.github.naoyukik.intellijplugingithubnotifications.domain.GitProviderService + +class GitProviderWorkflow( + private val gitProviderService: GitProviderService, +) { + fun getGitRepositories(): List { + return gitProviderService.getGitRepositories().map { + GitRepositoryDto(it.name) + } + } +} diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/dto/GitRepositoryDto.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/dto/GitRepositoryDto.kt new file mode 100644 index 00000000..dae6a518 --- /dev/null +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/application/dto/GitRepositoryDto.kt @@ -0,0 +1,3 @@ +package com.github.naoyukik.intellijplugingithubnotifications.application.dto + +data class GitRepositoryDto(val name: String) diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/GitProviderService.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/GitProviderService.kt new file mode 100644 index 00000000..930c6930 --- /dev/null +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/GitProviderService.kt @@ -0,0 +1,19 @@ +package com.github.naoyukik.intellijplugingithubnotifications.domain + +import com.github.naoyukik.intellijplugingithubnotifications.domain.model.GitRepository +import com.intellij.openapi.project.Project +import com.intellij.openapi.vcs.ProjectLevelVcsManager + +class GitProviderService( + private val project: Project, +) { + fun getGitRepositories(): List { + val vcsManager = ProjectLevelVcsManager.getInstance(project) + val allVcsRoots = vcsManager.allVcsRoots + val result = mutableListOf() + allVcsRoots.forEach { + result.add(GitRepository(it.path.name)) + } + return result + } +} diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/model/GitRepository.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/model/GitRepository.kt new file mode 100644 index 00000000..0f30bc07 --- /dev/null +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/domain/model/GitRepository.kt @@ -0,0 +1,3 @@ +package com.github.naoyukik.intellijplugingithubnotifications.domain.model + +data class GitRepository(val name: String) From 4d3152dcc8d9a1a69a2c82f274e0c88790896893 Mon Sep 17 00:00:00 2001 From: Kodama Naoyuki Date: Tue, 28 Jan 2025 22:22:00 +0900 Subject: [PATCH 2/2] feat: integrate repository selection into settings panel --- .../settings/AppSettingsComponent.kt | 13 ++++++++++++- .../settings/AppSettingsConfigurable.kt | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsComponent.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsComponent.kt index fc0dcefe..59907b16 100644 --- a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsComponent.kt +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsComponent.kt @@ -1,5 +1,10 @@ package com.github.naoyukik.intellijplugingithubnotifications.settings +import com.github.naoyukik.intellijplugingithubnotifications.application.GitProviderWorkflow +import com.github.naoyukik.intellijplugingithubnotifications.application.dto.GitRepositoryDto +import com.github.naoyukik.intellijplugingithubnotifications.domain.GitProviderService +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.ComboBox import com.intellij.ui.JBIntSpinner import com.intellij.ui.components.JBLabel import com.intellij.ui.components.JBTextField @@ -12,7 +17,9 @@ import javax.swing.JPanel /** * Supports creating and managing a [JPanel] for the Settings Dialog. */ -class AppSettingsComponent { +class AppSettingsComponent( + project: Project, +) { companion object { private const val PADDING = 5 private const val FETCH_INTERVAL_DEFAULT_VALUE = 15 @@ -26,8 +33,12 @@ class AppSettingsComponent { JBIntSpinner(FETCH_INTERVAL_DEFAULT_VALUE, FETCH_INTERVAL_MIN_VALUE, FETCH_INTERVAL_MAX_VALUE, 1) private val customizedRepositoryName = JBTextField(TEXT_AREA_COLUMNS) private val customizedGhCliPath = JBTextField(TEXT_AREA_COLUMNS) + private val repositoryComboBox: ComboBox init { + val vcsRepositoryProvider = GitProviderWorkflow(GitProviderService(project)) + val gitRepositories = vcsRepositoryProvider.getGitRepositories() + repositoryComboBox = ComboBox(gitRepositories.toTypedArray()) mainPanel = FormBuilder.createFormBuilder() .addLabeledComponent( JBLabel("Fetch interval:"), diff --git a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsConfigurable.kt b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsConfigurable.kt index 62a98d70..63a0fc88 100644 --- a/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsConfigurable.kt +++ b/src/main/kotlin/com/github/naoyukik/intellijplugingithubnotifications/settings/AppSettingsConfigurable.kt @@ -2,6 +2,7 @@ package com.github.naoyukik.intellijplugingithubnotifications.settings import com.intellij.openapi.options.Configurable import com.intellij.openapi.project.Project +import com.intellij.platform.ide.progress.ModalTaskOwner.project import org.jetbrains.annotations.Nls import javax.swing.JComponent @@ -13,7 +14,7 @@ class AppSettingsConfigurable(project: Project) : Configurable { private var mySettingsState: AppSettingsState? = null init { - mySettingsComponent = AppSettingsComponent() + mySettingsComponent = AppSettingsComponent(project) mySettingsState = AppSettingsState.getInstance(project) } @@ -27,7 +28,7 @@ class AppSettingsConfigurable(project: Project) : Configurable { } override fun createComponent(): JComponent? { - mySettingsComponent = AppSettingsComponent() + // mySettingsComponent = AppSettingsComponent(project) return mySettingsComponent?.getPanel() }