From 4978af23d8b46eb5cf006e8f8116d449fcd56acf Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Fri, 7 Apr 2023 04:34:07 +0200 Subject: [PATCH] Implemented option to open submodule in a new tab --- src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt | 3 +++ .../gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt b/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt index 8a8fe87..7d704f7 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt @@ -6,6 +6,7 @@ import com.jetpackduba.gitnuro.AppStateManager import com.jetpackduba.gitnuro.credentials.CredentialsStateManager import com.jetpackduba.gitnuro.di.modules.AppModule import com.jetpackduba.gitnuro.preferences.AppSettings +import com.jetpackduba.gitnuro.ui.TabsManager import com.jetpackduba.gitnuro.viewmodels.SettingsViewModel import dagger.Component import javax.inject.Singleton @@ -25,4 +26,6 @@ interface AppComponent { fun appPreferences(): AppSettings fun appEnvInfo(): AppEnvInfo + + fun tabsManager(): TabsManager } \ No newline at end of file diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt index d8ebb8f..e37cc89 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt @@ -6,6 +6,7 @@ import com.jetpackduba.gitnuro.git.TabState import com.jetpackduba.gitnuro.git.submodules.GetSubmodulesUseCase import com.jetpackduba.gitnuro.git.submodules.InitializeSubmoduleUseCase import com.jetpackduba.gitnuro.git.submodules.UpdateSubmoduleUseCase +import com.jetpackduba.gitnuro.ui.TabsManager import dagger.assisted.Assisted import dagger.assisted.AssistedInject import kotlinx.coroutines.CoroutineScope @@ -20,6 +21,7 @@ class SubmodulesViewModel @AssistedInject constructor( private val initializeSubmoduleUseCase: InitializeSubmoduleUseCase, private val updateSubmoduleUseCase: UpdateSubmoduleUseCase, private val tabScope: CoroutineScope, + private val tabsManager: TabsManager, @Assisted private val filter: StateFlow, ) : SidePanelChildViewModel(true) { @@ -70,8 +72,8 @@ class SubmodulesViewModel @AssistedInject constructor( loadSubmodules(git) } - fun onOpenSubmoduleInTab(@Suppress("UNUSED_PARAMETER") path: String) { - TODO() + fun onOpenSubmoduleInTab(path: String) = tabState.runOperation(refreshType = RefreshType.NONE) { git -> + tabsManager.addNewTabFromPath("${git.repository.directory.parent}/$path", true) } }