-
-
Notifications
You must be signed in to change notification settings - Fork 67
#303 Open File in Folder #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add function to context menu for unstaged, staged and commited files - Add File extention function to open a folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your MR! I've added a few comments to fix some issues before merging it.
src/main/kotlin/com/jetpackduba/gitnuro/extensions/FileExtensions.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/jetpackduba/gitnuro/extensions/FileExtensions.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/Status.kt
Outdated
Show resolved
Hide resolved
|
||
add( | ||
ContextMenuElement.ContextTextEntry( | ||
label = "Open file in folder", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use string resources for any new strings (The old ones are still being migrated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was delighted to see that localization already started. I tried to use the resources but as this in a non composable context, I cannot simply access the resources. How should I do this? Hand down the Strings into the context menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, it's a bit tricky out of the box. I've pushed some changes in the main branch to add proper support. If you rebase it, you will also see some examples as I extracted the rest of strings in that context menu.
- Use printError instead of println - Revert formatting of Status.kt - Change RefreshType to NONE
@JetpackDuba while working on the improvements, I realized that the changes do not actually open the repository folder, but the development folder of the project. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DiffEntry.parentDirectoryPath does not provide the full path of the repository. I could not find on how to the path of the repository, could you please point me in the right direction?
When running an operation from any of the view models, you have access to the git
object of that repository. From that object you can get the File
instance pointing to the repository:
fun example() = tabState.runOperation(
refreshType = RefreshType.NONE,
) { git ->
val repositoryFile = git.repository.workTree
// TODO Do something with the repository file
}
fun openFileInFolder(folderPath: String?) = tabState.runOperation( | ||
refreshType = RefreshType.NONE, | ||
) { | ||
folderPath?.let { File(it).openFileInFolder() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I forgot to mention it last time: Use a regular if
statement instead of let, it's more readable when checking nullability of parameters
|
||
add( | ||
ContextMenuElement.ContextTextEntry( | ||
label = "Open file in folder", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, it's a bit tricky out of the box. I've pushed some changes in the main branch to add proper support. If you rebase it, you will also see some examples as I extracted the rest of strings in that context menu.
Tested only with Ubuntu LTS 24.04.2, GNOME 46.0