mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[lvcs] use better presentation for single-change activity items
GitOrigin-RevId: 304ea72dc53f231ffd53746cbc416695f66b5b1f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
02bcab70e3
commit
d8b06497f6
@@ -69,9 +69,14 @@ activity.list.empty.text.recent=No recent activity detected
|
||||
activity.list.empty.text.recent.matching=No matching recent activity detected
|
||||
activity.list.empty.text.in.scope=No activity in {0} detected
|
||||
activity.list.empty.text.in.scope.matching=No matching activity in {0} detected
|
||||
activity.item.presentation=Changes
|
||||
activity.item.presentation.from.path=Changes in {0}
|
||||
activity.item.presentation.from.paths=Changes in {0} + {1} more
|
||||
activity.item.presentation=Change
|
||||
activity.item.presentation.from.path=Change {0}
|
||||
activity.item.presentation.from.paths=Change {0} + {1} more
|
||||
activity.item.presentation.create.path=Create {0}
|
||||
activity.item.presentation.delete.path=Delete {0}
|
||||
activity.item.presentation.rename.path=Rename {0} to {1}
|
||||
activity.item.presentation.move.path=Move {0} to {1}
|
||||
activity.item.presentation.modify.path=Modify {0}
|
||||
activity.filter.empty.text.content=Search by content
|
||||
activity.filter.empty.text.fileName=Search by file name
|
||||
activity.browser.empty.text=No changes detected
|
||||
|
||||
@@ -3,7 +3,8 @@ package com.intellij.platform.lvcs.impl
|
||||
|
||||
import com.intellij.history.ActivityId
|
||||
import com.intellij.history.core.Paths
|
||||
import com.intellij.history.core.changes.ChangeSet
|
||||
import com.intellij.history.core.changes.*
|
||||
import com.intellij.history.integration.CommonActivity
|
||||
import com.intellij.history.integration.LocalHistoryBundle
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
@@ -27,10 +28,29 @@ internal class ChangeActivityItem(changeSet: ChangeSet, scope: ActivityScope) :
|
||||
override val name = getName(changeSet, scope)
|
||||
|
||||
private fun getName(changeSet: ChangeSet, scope: ActivityScope): @NlsContexts.Label String? {
|
||||
if (changeSet.activityId == CommonActivity.ExternalChange || changeSet.name == null) {
|
||||
val nameFromSingleChange = getNameFromSingleChange(changeSet, scope)
|
||||
if (nameFromSingleChange != null) return nameFromSingleChange
|
||||
}
|
||||
if (changeSet.name != null) return changeSet.name
|
||||
if (!scope.hasMultipleFiles) return LocalHistoryBundle.message("activity.item.presentation")
|
||||
return changeSet.presentableNameFromPaths()
|
||||
}
|
||||
|
||||
private fun getNameFromSingleChange(changeSet: ChangeSet, scope: ActivityScope): @NlsContexts.Label String? {
|
||||
val singleChange = changeSet.changes.singleOrNull() ?: return null
|
||||
return when (singleChange) {
|
||||
is CreateEntryChange -> LocalHistoryBundle.message("activity.item.presentation.create.path", Paths.getNameOf(singleChange.path))
|
||||
is DeleteChange -> LocalHistoryBundle.message("activity.item.presentation.delete.path", Paths.getNameOf(singleChange.path))
|
||||
is RenameChange -> LocalHistoryBundle.message("activity.item.presentation.rename.path", singleChange.oldName, Paths.getNameOf(singleChange.path))
|
||||
is MoveChange -> LocalHistoryBundle.message("activity.item.presentation.move.path", Paths.getNameOf(singleChange.path),
|
||||
Paths.getNameOf(Paths.getParentOf(singleChange.path)))
|
||||
is ContentChange ->
|
||||
if (scope.hasMultipleFiles) LocalHistoryBundle.message("activity.item.presentation.modify.path", Paths.getNameOf(singleChange.path))
|
||||
else null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ChangeSet.presentableNameFromPaths(): @NlsContexts.Label String? {
|
||||
|
||||
@@ -79,9 +79,9 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val directoryActivity = provider.loadActivityList(scope, null)
|
||||
TestCase.assertEquals(4, directoryActivity.items.size)
|
||||
TestCase.assertEquals(listOf("label",
|
||||
"Changes in file.txt",
|
||||
"Changes in file.txt",
|
||||
"Changes in directory"), directoryActivity.getNamesList())
|
||||
"Modify ${file.name}",
|
||||
"Create ${file.name}",
|
||||
"Create ${directory.name}"), directoryActivity.getNamesList())
|
||||
}
|
||||
|
||||
fun `test recent activity`() {
|
||||
@@ -143,12 +143,12 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
|
||||
TestCase.assertEquals(listOf(visibleLabel,
|
||||
"Changes in ${otherFile.name}",
|
||||
"Changes in ${file.name}",
|
||||
"Changes in ${otherFile.name}",
|
||||
"Changes in ${file.name}",
|
||||
"External change",
|
||||
"External change"), activityList.getNamesList())
|
||||
"Modify ${otherFile.name}",
|
||||
"Modify ${file.name}",
|
||||
"Modify ${otherFile.name}",
|
||||
"Modify ${file.name}",
|
||||
"Create ${otherFile.name}",
|
||||
"Create ${file.name}"), activityList.getNamesList())
|
||||
}
|
||||
|
||||
fun `test parent directory and child file history`() {
|
||||
@@ -171,12 +171,12 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
|
||||
TestCase.assertEquals(listOf("Changes in ${file.name}",
|
||||
TestCase.assertEquals(listOf("Modify ${file.name}",
|
||||
moveActionName,
|
||||
"Changes in ${file.name}",
|
||||
"Changes in ${file.name}",
|
||||
"Changes in directory" /* directory created */,
|
||||
"External change" /* file created */), activityList.getNamesList())
|
||||
"Modify ${file.name}",
|
||||
"Modify ${file.name}",
|
||||
"Create ${directory.name}",
|
||||
"Create ${file.name}"), activityList.getNamesList())
|
||||
}
|
||||
|
||||
fun `test diff data`() {
|
||||
|
||||
Reference in New Issue
Block a user