-
-
Notifications
You must be signed in to change notification settings - Fork 69
#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?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
JetpackDuba marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package com.jetpackduba.gitnuro.ui.context_menu | |
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import com.jetpackduba.gitnuro.generated.resources.Res | ||
import com.jetpackduba.gitnuro.generated.resources.blame | ||
import com.jetpackduba.gitnuro.generated.resources.folder_open | ||
import com.jetpackduba.gitnuro.generated.resources.history | ||
import org.eclipse.jgit.diff.DiffEntry | ||
import org.jetbrains.compose.resources.painterResource | ||
|
@@ -12,6 +13,7 @@ fun committedChangesEntriesContextMenuItems( | |
diffEntry: DiffEntry, | ||
onBlame: () -> Unit, | ||
onHistory: () -> Unit, | ||
onOpenFileInFolder: () -> Unit, | ||
): List<ContextMenuElement> { | ||
return mutableListOf<ContextMenuElement>().apply { | ||
if (diffEntry.changeType != DiffEntry.ChangeType.ADD || | ||
|
@@ -31,6 +33,14 @@ fun committedChangesEntriesContextMenuItems( | |
onClick = onHistory, | ||
) | ||
) | ||
|
||
add( | ||
ContextMenuElement.ContextTextEntry( | ||
label = "Open file in folder", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
icon = { painterResource(Res.drawable.folder_open) }, | ||
onClick = onOpenFileInFolder, | ||
) | ||
) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,7 @@ package com.jetpackduba.gitnuro.viewmodels | |
import androidx.compose.foundation.ScrollState | ||
import androidx.compose.foundation.lazy.LazyListState | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import com.jetpackduba.gitnuro.extensions.delayedStateChange | ||
import com.jetpackduba.gitnuro.extensions.filePath | ||
import com.jetpackduba.gitnuro.extensions.fullData | ||
import com.jetpackduba.gitnuro.extensions.lowercaseContains | ||
import com.jetpackduba.gitnuro.extensions.* | ||
import com.jetpackduba.gitnuro.git.CloseableView | ||
import com.jetpackduba.gitnuro.git.RefreshType | ||
import com.jetpackduba.gitnuro.git.TabState | ||
|
@@ -19,6 +16,7 @@ import kotlinx.coroutines.flow.* | |
import kotlinx.coroutines.launch | ||
import org.eclipse.jgit.diff.DiffEntry | ||
import org.eclipse.jgit.revwalk.RevCommit | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
private const val MIN_TIME_IN_MS_TO_SHOW_LOAD = 300L | ||
|
@@ -159,6 +157,12 @@ class CommitChangesViewModel @Inject constructor( | |
appSettingsRepository.showChangesAsTree = !appSettingsRepository.showChangesAsTree | ||
} | ||
|
||
fun openFileInFolder(folderPath: String?) = tabState.runOperation( | ||
refreshType = RefreshType.UNCOMMITTED_CHANGES, | ||
) { | ||
folderPath?.let { File(it).openFileInFolder() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I forgot to mention it last time: Use a regular |
||
} | ||
|
||
fun onDirectoryClicked(directoryPath: String) { | ||
val contractedDirectories = treeContractedDirectories.value | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.