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(
|
RemoteBranches(
|
||||||
remoteBranch = remoteBranch,
|
remoteBranch = remoteBranch,
|
||||||
onBranchClicked = { remotesViewModel.selectBranch(remoteBranch) },
|
onBranchClicked = { remotesViewModel.selectBranch(remoteBranch) },
|
||||||
|
onDoubleClick = { remotesViewModel.checkoutRemoteBranch(remoteBranch) },
|
||||||
onDeleteBranch = { remotesViewModel.deleteRemoteBranch(remoteBranch) },
|
onDeleteBranch = { remotesViewModel.deleteRemoteBranch(remoteBranch) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -412,6 +413,7 @@ private fun Remote(
|
|||||||
private fun RemoteBranches(
|
private fun RemoteBranches(
|
||||||
remoteBranch: Ref,
|
remoteBranch: Ref,
|
||||||
onBranchClicked: () -> Unit,
|
onBranchClicked: () -> Unit,
|
||||||
|
onDoubleClick: () -> Unit,
|
||||||
onDeleteBranch: () -> Unit,
|
onDeleteBranch: () -> Unit,
|
||||||
) {
|
) {
|
||||||
ContextMenu(
|
ContextMenu(
|
||||||
@ -425,7 +427,8 @@ private fun RemoteBranches(
|
|||||||
text = remoteBranch.simpleName,
|
text = remoteBranch.simpleName,
|
||||||
extraPadding = 24.dp,
|
extraPadding = 24.dp,
|
||||||
iconResourcePath = AppIcons.BRANCH,
|
iconResourcePath = AppIcons.BRANCH,
|
||||||
onClick = onBranchClicked
|
onClick = onBranchClicked,
|
||||||
|
onDoubleClick = onDoubleClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,15 +46,6 @@ fun branchContextMenuItems(
|
|||||||
add(ContextMenuElement.ContextSeparator)
|
add(ContextMenuElement.ContextSeparator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isLocal && !isCurrentBranch) {
|
|
||||||
add(
|
|
||||||
ContextMenuElement.ContextTextEntry(
|
|
||||||
label = "Delete branch",
|
|
||||||
icon = { painterResource(AppIcons.DELETE) },
|
|
||||||
onClick = onDeleteBranch
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (!isLocal && currentBranch != null && !currentBranch.isHead) {
|
if (!isLocal && currentBranch != null && !currentBranch.isHead) {
|
||||||
add(
|
add(
|
||||||
ContextMenuElement.ContextTextEntry(
|
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) {
|
if (lastOrNull() == ContextMenuElement.ContextSeparator) {
|
||||||
removeLast()
|
removeLast()
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.jetpackduba.gitnuro.extensions.lowercaseContains
|
|||||||
import com.jetpackduba.gitnuro.extensions.simpleName
|
import com.jetpackduba.gitnuro.extensions.simpleName
|
||||||
import com.jetpackduba.gitnuro.git.RefreshType
|
import com.jetpackduba.gitnuro.git.RefreshType
|
||||||
import com.jetpackduba.gitnuro.git.TabState
|
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.DeleteLocallyRemoteBranchesUseCase
|
||||||
import com.jetpackduba.gitnuro.git.branches.GetRemoteBranchesUseCase
|
import com.jetpackduba.gitnuro.git.branches.GetRemoteBranchesUseCase
|
||||||
import com.jetpackduba.gitnuro.git.remote_operations.DeleteRemoteBranchUseCase
|
import com.jetpackduba.gitnuro.git.remote_operations.DeleteRemoteBranchUseCase
|
||||||
@ -30,6 +31,7 @@ class RemotesViewModel @AssistedInject constructor(
|
|||||||
private val addRemoteUseCase: AddRemoteUseCase,
|
private val addRemoteUseCase: AddRemoteUseCase,
|
||||||
private val updateRemoteUseCase: UpdateRemoteUseCase,
|
private val updateRemoteUseCase: UpdateRemoteUseCase,
|
||||||
private val deleteLocallyRemoteBranchesUseCase: DeleteLocallyRemoteBranchesUseCase,
|
private val deleteLocallyRemoteBranchesUseCase: DeleteLocallyRemoteBranchesUseCase,
|
||||||
|
private val checkoutRefUseCase: CheckoutRefUseCase,
|
||||||
private val tabScope: CoroutineScope,
|
private val tabScope: CoroutineScope,
|
||||||
@Assisted
|
@Assisted
|
||||||
private val filter: StateFlow<String>
|
private val filter: StateFlow<String>
|
||||||
@ -169,6 +171,12 @@ class RemotesViewModel @AssistedInject constructor(
|
|||||||
uriType = RemoteSetUrlCommand.UriType.PUSH
|
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)
|
data class RemoteView(val remoteInfo: RemoteInfo, val isExpanded: Boolean)
|
||||||
|
Loading…
Reference in New Issue
Block a user