Double click on remote branch in the side panel now creates a local copy
This commit is contained in:
parent
5b5aa136d0
commit
73816089a6
@ -228,6 +228,7 @@ fun LazyListScope.remotes(
|
||||
RemoteBranches(
|
||||
remoteBranch = remoteBranch,
|
||||
onBranchClicked = { remotesViewModel.selectBranch(remoteBranch) },
|
||||
onDoubleClick = { remotesViewModel.checkoutRemoteBranch(remoteBranch) },
|
||||
onDeleteBranch = { remotesViewModel.deleteRemoteBranch(remoteBranch) },
|
||||
)
|
||||
}
|
||||
@ -412,6 +413,7 @@ private fun Remote(
|
||||
private fun RemoteBranches(
|
||||
remoteBranch: Ref,
|
||||
onBranchClicked: () -> Unit,
|
||||
onDoubleClick: () -> Unit,
|
||||
onDeleteBranch: () -> Unit,
|
||||
) {
|
||||
ContextMenu(
|
||||
@ -425,7 +427,8 @@ private fun RemoteBranches(
|
||||
text = remoteBranch.simpleName,
|
||||
extraPadding = 24.dp,
|
||||
iconResourcePath = AppIcons.BRANCH,
|
||||
onClick = onBranchClicked
|
||||
onClick = onBranchClicked,
|
||||
onDoubleClick = onDoubleClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -46,15 +46,6 @@ fun branchContextMenuItems(
|
||||
add(ContextMenuElement.ContextSeparator)
|
||||
}
|
||||
}
|
||||
if (isLocal && !isCurrentBranch) {
|
||||
add(
|
||||
ContextMenuElement.ContextTextEntry(
|
||||
label = "Delete branch",
|
||||
icon = { painterResource(AppIcons.DELETE) },
|
||||
onClick = onDeleteBranch
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!isLocal && currentBranch != null && !currentBranch.isHead) {
|
||||
add(
|
||||
ContextMenuElement.ContextTextEntry(
|
||||
@ -89,6 +80,16 @@ fun branchContextMenuItems(
|
||||
)
|
||||
}
|
||||
|
||||
if (isLocal && !isCurrentBranch) {
|
||||
add(
|
||||
ContextMenuElement.ContextTextEntry(
|
||||
label = "Delete branch",
|
||||
icon = { painterResource(AppIcons.DELETE) },
|
||||
onClick = onDeleteBranch
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (lastOrNull() == ContextMenuElement.ContextSeparator) {
|
||||
removeLast()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.jetpackduba.gitnuro.extensions.lowercaseContains
|
||||
import com.jetpackduba.gitnuro.extensions.simpleName
|
||||
import com.jetpackduba.gitnuro.git.RefreshType
|
||||
import com.jetpackduba.gitnuro.git.TabState
|
||||
import com.jetpackduba.gitnuro.git.branches.CheckoutRefUseCase
|
||||
import com.jetpackduba.gitnuro.git.branches.DeleteLocallyRemoteBranchesUseCase
|
||||
import com.jetpackduba.gitnuro.git.branches.GetRemoteBranchesUseCase
|
||||
import com.jetpackduba.gitnuro.git.remote_operations.DeleteRemoteBranchUseCase
|
||||
@ -30,6 +31,7 @@ class RemotesViewModel @AssistedInject constructor(
|
||||
private val addRemoteUseCase: AddRemoteUseCase,
|
||||
private val updateRemoteUseCase: UpdateRemoteUseCase,
|
||||
private val deleteLocallyRemoteBranchesUseCase: DeleteLocallyRemoteBranchesUseCase,
|
||||
private val checkoutRefUseCase: CheckoutRefUseCase,
|
||||
private val tabScope: CoroutineScope,
|
||||
@Assisted
|
||||
private val filter: StateFlow<String>
|
||||
@ -169,6 +171,12 @@ class RemotesViewModel @AssistedInject constructor(
|
||||
uriType = RemoteSetUrlCommand.UriType.PUSH
|
||||
)
|
||||
}
|
||||
|
||||
fun checkoutRemoteBranch(remoteBranch: Ref) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
) { git ->
|
||||
checkoutRefUseCase(git, remoteBranch)
|
||||
}
|
||||
}
|
||||
|
||||
data class RemoteView(val remoteInfo: RemoteInfo, val isExpanded: Boolean)
|
||||
|
Loading…
Reference in New Issue
Block a user