Added loading screen title+subtitle for LogViewModel methods
This commit is contained in:
parent
1facd863ba
commit
45e4f9e799
@ -10,6 +10,10 @@ fun RevCommit.fullData(repository: Repository): RevCommit? {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val RevCommit.shortName: String
|
||||||
|
get() = this.name().orEmpty().take(7)
|
||||||
|
|
||||||
|
|
||||||
fun RevCommit.getShortMessageTrimmed(): String {
|
fun RevCommit.getShortMessageTrimmed(): String {
|
||||||
return (this.fullMessage ?: "")
|
return (this.fullMessage ?: "")
|
||||||
.trimStart()
|
.trimStart()
|
||||||
|
@ -206,17 +206,18 @@ fun CommitChangesView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Author(commit.id, commit.authorIdent)
|
Author(commit.shortName, commit.name, commit.authorIdent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Author(
|
fun Author(
|
||||||
id: ObjectId,
|
shortName: String,
|
||||||
|
name: String,
|
||||||
author: PersonIdent,
|
author: PersonIdent,
|
||||||
) {
|
) {
|
||||||
var copied by remember(id) { mutableStateOf(false) }
|
var copied by remember(name) { mutableStateOf(false) }
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val clipboard = LocalClipboardManager.current
|
val clipboard = LocalClipboardManager.current
|
||||||
|
|
||||||
@ -248,13 +249,13 @@ fun Author(
|
|||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
text = id.abbreviate(7).name(),
|
text = shortName,
|
||||||
color = MaterialTheme.colors.onBackgroundSecondary,
|
color = MaterialTheme.colors.onBackgroundSecondary,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
modifier = Modifier.handMouseClickable {
|
modifier = Modifier.handMouseClickable {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
clipboard.setText(AnnotatedString(id.name))
|
clipboard.setText(AnnotatedString(name))
|
||||||
copied = true
|
copied = true
|
||||||
delay(2000) // 2s
|
delay(2000) // 2s
|
||||||
copied = false
|
copied = false
|
||||||
|
@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import com.jetpackduba.gitnuro.AppIcons
|
import com.jetpackduba.gitnuro.AppIcons
|
||||||
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
||||||
import com.jetpackduba.gitnuro.extensions.handOnHover
|
import com.jetpackduba.gitnuro.extensions.handOnHover
|
||||||
|
import com.jetpackduba.gitnuro.extensions.shortName
|
||||||
import com.jetpackduba.gitnuro.extensions.toSmartSystemString
|
import com.jetpackduba.gitnuro.extensions.toSmartSystemString
|
||||||
import com.jetpackduba.gitnuro.git.diff.DiffResult
|
import com.jetpackduba.gitnuro.git.diff.DiffResult
|
||||||
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
||||||
@ -237,7 +238,7 @@ fun HistoryCommit(commit: RevCommit, onCommitSelected: () -> Unit) {
|
|||||||
|
|
||||||
Row {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = commit.name.take(7),
|
text = commit.shortName,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
color = MaterialTheme.colors.onBackgroundSecondary,
|
color = MaterialTheme.colors.onBackgroundSecondary,
|
||||||
|
@ -76,6 +76,8 @@ class HistoryViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun fileHistory(filePath: String) = tabState.safeProcessing(
|
fun fileHistory(filePath: String) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.NONE,
|
refreshType = RefreshType.NONE,
|
||||||
|
title = "History",
|
||||||
|
subtitle = "Loading file history",
|
||||||
) { git ->
|
) { git ->
|
||||||
this@HistoryViewModel.filePath = filePath
|
this@HistoryViewModel.filePath = filePath
|
||||||
_historyState.value = HistoryState.Loading(filePath)
|
_historyState.value = HistoryState.Loading(filePath)
|
||||||
|
@ -3,6 +3,8 @@ package com.jetpackduba.gitnuro.viewmodels
|
|||||||
import androidx.compose.foundation.ScrollState
|
import androidx.compose.foundation.ScrollState
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import com.jetpackduba.gitnuro.extensions.delayedStateChange
|
import com.jetpackduba.gitnuro.extensions.delayedStateChange
|
||||||
|
import com.jetpackduba.gitnuro.extensions.shortName
|
||||||
|
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.TaskEvent
|
import com.jetpackduba.gitnuro.git.TaskEvent
|
||||||
@ -162,6 +164,8 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun pushToRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
fun pushToRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Push",
|
||||||
|
subtitle = "Pushing current branch to ${branch.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
pushToSpecificBranchUseCase(
|
pushToSpecificBranchUseCase(
|
||||||
git = git,
|
git = git,
|
||||||
@ -173,6 +177,8 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun pullFromRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
fun pullFromRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Pull",
|
||||||
|
subtitle = "Pulling changes from ${branch.simpleName} to the current branch",
|
||||||
) { git ->
|
) { git ->
|
||||||
pullFromSpecificBranchUseCase(
|
pullFromSpecificBranchUseCase(
|
||||||
git = git,
|
git = git,
|
||||||
@ -183,6 +189,8 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun checkoutCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
fun checkoutCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Commit checkout",
|
||||||
|
subtitle = "Checking out commit ${revCommit.name}",
|
||||||
) { git ->
|
) { git ->
|
||||||
checkoutCommitUseCase(git, revCommit)
|
checkoutCommitUseCase(git, revCommit)
|
||||||
}
|
}
|
||||||
@ -190,24 +198,32 @@ class LogViewModel @Inject constructor(
|
|||||||
fun revertCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
fun revertCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashes = true,
|
refreshEvenIfCrashes = true,
|
||||||
|
title = "Commit revert",
|
||||||
|
subtitle = "Reverting commit ${revCommit.name}",
|
||||||
) { git ->
|
) { git ->
|
||||||
revertCommitUseCase(git, revCommit)
|
revertCommitUseCase(git, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToCommit(revCommit: RevCommit, resetType: ResetType) = tabState.safeProcessing(
|
fun resetToCommit(revCommit: RevCommit, resetType: ResetType) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Branch reset",
|
||||||
|
subtitle = "Reseting branch to commit ${revCommit.shortName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
resetToCommitUseCase(git, revCommit, resetType = resetType)
|
resetToCommitUseCase(git, revCommit, resetType = resetType)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkoutRef(ref: Ref) = tabState.safeProcessing(
|
fun checkoutRef(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Branch checkout",
|
||||||
|
subtitle = "Checking out branch ${ref.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
checkoutRefUseCase(git, ref)
|
checkoutRefUseCase(git, ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cherrypickCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
fun cherrypickCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
||||||
|
title = "Cherry-pick",
|
||||||
|
subtitle = "Cherry-picking commit ${revCommit.shortName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
cherryPickCommitUseCase(git, revCommit)
|
cherryPickCommitUseCase(git, revCommit)
|
||||||
}
|
}
|
||||||
@ -215,38 +231,44 @@ class LogViewModel @Inject constructor(
|
|||||||
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing(
|
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashesInteractive = { it is CheckoutConflictException },
|
refreshEvenIfCrashesInteractive = { it is CheckoutConflictException },
|
||||||
|
title = "New branch",
|
||||||
|
subtitle = "Creating new branch \"$branch\" on commit ${revCommit.shortName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
createBranchOnCommitUseCase(git, branch, revCommit)
|
createBranchOnCommitUseCase(git, branch, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createTagOnCommit(tag: String, revCommit: RevCommit) = tabState.safeProcessing(
|
fun createTagOnCommit(tag: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "New tag",
|
||||||
|
subtitle = "Creating new tag \"$tag\" on commit ${revCommit.shortName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
createTagOnCommitUseCase(git, tag, revCommit)
|
createTagOnCommitUseCase(git, tag, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mergeBranch(ref: Ref) = tabState.safeProcessing(
|
fun mergeBranch(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Branch merge",
|
||||||
|
subtitle = "Merging branch ${ref.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
mergeBranchUseCase(git, ref, appSettings.ffMerge)
|
mergeBranchUseCase(git, ref, appSettings.ffMerge)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteBranch(branch: Ref) = tabState.safeProcessing(
|
fun deleteBranch(branch: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Branch delete",
|
||||||
|
subtitle = "Deleting branch ${branch.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
deleteBranchUseCase(git, branch)
|
deleteBranchUseCase(git, branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteTag(tag: Ref) = tabState.safeProcessing(
|
fun deleteTag(tag: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Tag delete",
|
||||||
|
subtitle = "Deleting tag ${tag.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
deleteTagUseCase(git, tag)
|
deleteTagUseCase(git, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun refreshUncommitedChanges(git: Git) {
|
|
||||||
uncommitedChangesLoadLog(git)
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun uncommitedChangesLoadLog(git: Git) {
|
private suspend fun uncommitedChangesLoadLog(git: Git) {
|
||||||
val currentBranch = getCurrentBranchUseCase(git)
|
val currentBranch = getCurrentBranchUseCase(git)
|
||||||
val hasUncommitedChanges = checkHasUncommitedChangedUseCase(git)
|
val hasUncommitedChanges = checkHasUncommitedChangedUseCase(git)
|
||||||
@ -279,6 +301,8 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun rebaseBranch(ref: Ref) = tabState.safeProcessing(
|
fun rebaseBranch(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Branch rebase",
|
||||||
|
subtitle = "Rebasing branch ${ref.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
rebaseBranchUseCase(git, ref)
|
rebaseBranchUseCase(git, ref)
|
||||||
}
|
}
|
||||||
@ -412,6 +436,8 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun deleteRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
fun deleteRemoteBranch(branch: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
|
title = "Delete remote branch",
|
||||||
|
subtitle = "Deleting remote branch ${branch.simpleName}",
|
||||||
) { git ->
|
) { git ->
|
||||||
deleteRemoteBranchUseCase(git, branch)
|
deleteRemoteBranchUseCase(git, branch)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user