Implemented option to open submodule in a new tab

This commit is contained in:
Abdelilah El Aissaoui 2023-04-07 04:34:07 +02:00
parent 63df04e3ba
commit 4978af23d8
No known key found for this signature in database
GPG key ID: 7587FC860F594869
2 changed files with 7 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import com.jetpackduba.gitnuro.AppStateManager
import com.jetpackduba.gitnuro.credentials.CredentialsStateManager import com.jetpackduba.gitnuro.credentials.CredentialsStateManager
import com.jetpackduba.gitnuro.di.modules.AppModule import com.jetpackduba.gitnuro.di.modules.AppModule
import com.jetpackduba.gitnuro.preferences.AppSettings import com.jetpackduba.gitnuro.preferences.AppSettings
import com.jetpackduba.gitnuro.ui.TabsManager
import com.jetpackduba.gitnuro.viewmodels.SettingsViewModel import com.jetpackduba.gitnuro.viewmodels.SettingsViewModel
import dagger.Component import dagger.Component
import javax.inject.Singleton import javax.inject.Singleton
@ -25,4 +26,6 @@ interface AppComponent {
fun appPreferences(): AppSettings fun appPreferences(): AppSettings
fun appEnvInfo(): AppEnvInfo fun appEnvInfo(): AppEnvInfo
fun tabsManager(): TabsManager
} }

View file

@ -6,6 +6,7 @@ import com.jetpackduba.gitnuro.git.TabState
import com.jetpackduba.gitnuro.git.submodules.GetSubmodulesUseCase import com.jetpackduba.gitnuro.git.submodules.GetSubmodulesUseCase
import com.jetpackduba.gitnuro.git.submodules.InitializeSubmoduleUseCase import com.jetpackduba.gitnuro.git.submodules.InitializeSubmoduleUseCase
import com.jetpackduba.gitnuro.git.submodules.UpdateSubmoduleUseCase import com.jetpackduba.gitnuro.git.submodules.UpdateSubmoduleUseCase
import com.jetpackduba.gitnuro.ui.TabsManager
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -20,6 +21,7 @@ class SubmodulesViewModel @AssistedInject constructor(
private val initializeSubmoduleUseCase: InitializeSubmoduleUseCase, private val initializeSubmoduleUseCase: InitializeSubmoduleUseCase,
private val updateSubmoduleUseCase: UpdateSubmoduleUseCase, private val updateSubmoduleUseCase: UpdateSubmoduleUseCase,
private val tabScope: CoroutineScope, private val tabScope: CoroutineScope,
private val tabsManager: TabsManager,
@Assisted @Assisted
private val filter: StateFlow<String>, private val filter: StateFlow<String>,
) : SidePanelChildViewModel(true) { ) : SidePanelChildViewModel(true) {
@ -70,8 +72,8 @@ class SubmodulesViewModel @AssistedInject constructor(
loadSubmodules(git) loadSubmodules(git)
} }
fun onOpenSubmoduleInTab(@Suppress("UNUSED_PARAMETER") path: String) { fun onOpenSubmoduleInTab(path: String) = tabState.runOperation(refreshType = RefreshType.NONE) { git ->
TODO() tabsManager.addNewTabFromPath("${git.repository.directory.parent}/$path", true)
} }
} }