Errors now include the stacktrace

This commit is contained in:
Abdelilah El Aissaoui 2024-01-24 23:45:26 +01:00
parent d9bd6fc905
commit ed86583f58
No known key found for this signature in database
GPG key ID: 7587FC860F594869
9 changed files with 89 additions and 16 deletions

View file

@ -28,7 +28,7 @@ import com.jetpackduba.gitnuro.extensions.handMouseClickable
import com.jetpackduba.gitnuro.extensions.handOnHover
import com.jetpackduba.gitnuro.extensions.ignoreKeyEvents
import com.jetpackduba.gitnuro.git.remote_operations.PullType
import com.jetpackduba.gitnuro.ui.components.InstantTooltip
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
import com.jetpackduba.gitnuro.ui.components.gitnuroViewModel
import com.jetpackduba.gitnuro.ui.context_menu.*
import com.jetpackduba.gitnuro.viewmodels.MenuViewModel

View file

@ -19,6 +19,7 @@ import com.jetpackduba.gitnuro.extensions.isValid
import com.jetpackduba.gitnuro.extensions.simpleName
import com.jetpackduba.gitnuro.theme.onBackgroundSecondary
import com.jetpackduba.gitnuro.ui.components.*
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
import com.jetpackduba.gitnuro.ui.context_menu.*
import com.jetpackduba.gitnuro.ui.dialogs.AddSubmodulesDialog
import com.jetpackduba.gitnuro.ui.dialogs.EditRemotesDialog
@ -597,7 +598,7 @@ private fun Submodule(
},
) {
val stateName = submodule.second.type.toString()
Tooltip(stateName) {
DelayedTooltip(stateName) {
Text(
text = stateName.first().toString(),
color = MaterialTheme.colors.onBackgroundSecondary,

View file

@ -31,6 +31,8 @@ import com.jetpackduba.gitnuro.extensions.handMouseClickable
import com.jetpackduba.gitnuro.extensions.handOnHover
import com.jetpackduba.gitnuro.extensions.onMiddleMouseButtonClick
import com.jetpackduba.gitnuro.managers.AppStateManager
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
import com.jetpackduba.gitnuro.ui.drag_sorting.HorizontalDraggableItem
import com.jetpackduba.gitnuro.ui.drag_sorting.horizontalDragContainer
import com.jetpackduba.gitnuro.ui.drag_sorting.rememberHorizontalDragDropState
@ -80,7 +82,7 @@ fun RepositoriesTabPanel(
Column {
if (canBeScrolled) {
Tooltip(
DelayedTooltip(
"\"Shift + Mouse wheel\" to scroll"
) {
HorizontalScrollbar(

View file

@ -15,6 +15,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.TextUnit
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
@OptIn(ExperimentalFoundationApi::class)
@Composable
@ -37,7 +38,7 @@ fun TooltipText(
style: TextStyle = LocalTextStyle.current,
tooltipTitle: String,
) {
Tooltip(
DelayedTooltip(
text = tooltipTitle,
) {
Text(

View file

@ -1,4 +1,4 @@
package com.jetpackduba.gitnuro.ui.components
package com.jetpackduba.gitnuro.ui.components.tooltip
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
@ -15,7 +15,7 @@ import com.jetpackduba.gitnuro.theme.onBackgroundSecondary
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun Tooltip(text: String?, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
fun DelayedTooltip(text: String?, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
TooltipArea(
modifier = modifier,
tooltip = {

View file

@ -1,4 +1,4 @@
package com.jetpackduba.gitnuro.ui.components
package com.jetpackduba.gitnuro.ui.components.tooltip
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@ -6,7 +6,6 @@ import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@ -104,7 +103,6 @@ fun InstantTooltip(
modifier = Modifier.padding(8.dp)
)
}
}
}
}

View file

@ -1,25 +1,35 @@
package com.jetpackduba.gitnuro.ui.dialogs
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.jetpackduba.gitnuro.AppIcons
import com.jetpackduba.gitnuro.extensions.handOnHover
import com.jetpackduba.gitnuro.managers.Error
import com.jetpackduba.gitnuro.theme.secondarySurface
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
import kotlinx.coroutines.delay
@Composable
fun ErrorDialog(
error: Error,
onAccept: () -> Unit,
) {
val horizontalScroll = rememberScrollState()
val verticalScroll = rememberScrollState()
val clipboard = LocalClipboardManager.current
MaterialDialog {
Column(
modifier = Modifier
@ -52,6 +62,61 @@ fun ErrorDialog(
style = MaterialTheme.typography.body2,
)
Box(
modifier = Modifier
.padding(top = 24.dp)
.height(400.dp)
.fillMaxWidth()
) {
OutlinedTextField(
value = error.exception.stackTraceToString(),
onValueChange = {},
readOnly = true,
colors = TextFieldDefaults.outlinedTextFieldColors(backgroundColor = MaterialTheme.colors.secondarySurface),
textStyle = MaterialTheme.typography.body2,
modifier = Modifier
.fillMaxSize()
.horizontalScroll(horizontalScroll)
.verticalScroll(verticalScroll),
)
HorizontalScrollbar(
rememberScrollbarAdapter(horizontalScroll),
modifier = Modifier
.align(Alignment.BottomCenter)
.fillMaxWidth()
)
VerticalScrollbar(
rememberScrollbarAdapter(verticalScroll),
modifier = Modifier
.align(Alignment.CenterEnd)
.fillMaxHeight()
)
InstantTooltip(
"Copy error",
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(end = 16.dp, bottom = 16.dp)
) {
IconButton(
onClick = {
copyMessageError(clipboard, error.exception)
},
modifier = Modifier
.size(24.dp)
.handOnHover()
) {
Icon(
painter = painterResource(AppIcons.COPY),
contentDescription = "Copy stacktrace",
tint = MaterialTheme.colors.onSurface,
)
}
}
}
Row(
modifier = Modifier
.align(Alignment.End)
@ -64,4 +129,8 @@ fun ErrorDialog(
}
}
}
}
}
fun copyMessageError(clipboard: ClipboardManager, ex: Exception) {
clipboard.setText(AnnotatedString(ex.stackTraceToString()))
}

View file

@ -57,7 +57,7 @@ import com.jetpackduba.gitnuro.theme.*
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
import com.jetpackduba.gitnuro.ui.components.ScrollableLazyColumn
import com.jetpackduba.gitnuro.ui.components.SecondaryButton
import com.jetpackduba.gitnuro.ui.components.Tooltip
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
import com.jetpackduba.gitnuro.ui.context_menu.ContextMenu
import com.jetpackduba.gitnuro.ui.context_menu.ContextMenuElement
import com.jetpackduba.gitnuro.ui.context_menu.CustomTextContextMenu
@ -945,7 +945,7 @@ fun StateIcon(
isToggled: Boolean,
onClick: () -> Unit,
) {
Tooltip(tooltip) {
DelayedTooltip(tooltip) {
Box(
modifier = Modifier
.clip(RoundedCornerShape(4.dp))

View file

@ -46,6 +46,8 @@ import com.jetpackduba.gitnuro.keybindings.matchesBinding
import com.jetpackduba.gitnuro.theme.*
import com.jetpackduba.gitnuro.ui.SelectedItem
import com.jetpackduba.gitnuro.ui.components.*
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltipPosition
import com.jetpackduba.gitnuro.ui.context_menu.*
import com.jetpackduba.gitnuro.ui.dialogs.NewBranchDialog
import com.jetpackduba.gitnuro.ui.dialogs.NewTagDialog