mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
Revert "[gitlab] IJPL-204613 disable comments on unsupported file changes and show a warning"
This reverts commit a09e33fef456b374501bb7bf0479ae65e7369d1e. IJ-CR-179504 GitOrigin-RevId: 91b7d49a7845c064cd3f5ed805a169c356d7f738
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c7d6637615
commit
b86fd31e2a
@@ -1925,7 +1925,6 @@ f:com.intellij.diff.util.DiffUtil
|
||||
- s:addActionBlock(com.intellij.openapi.actionSystem.DefaultActionGroup,java.util.List,Z):V
|
||||
- s:addActionBlock(com.intellij.openapi.actionSystem.DefaultActionGroup,com.intellij.openapi.actionSystem.AnAction[]):V
|
||||
- s:addNotification(com.intellij.diff.util.DiffNotificationProvider,com.intellij.openapi.util.UserDataHolder):V
|
||||
- s:addNotificationIfAbsent(com.intellij.diff.util.DiffNotificationProvider,com.intellij.openapi.util.UserDataHolder):V
|
||||
- s:addTitleCustomizers(com.intellij.diff.merge.MergeRequest,java.util.List):com.intellij.diff.merge.MergeRequest
|
||||
- s:addTitleCustomizers(com.intellij.diff.requests.DiffRequest,java.util.List):com.intellij.diff.requests.DiffRequest
|
||||
- s:addTitleCustomizers(com.intellij.diff.requests.DiffRequest,com.intellij.diff.DiffEditorTitleCustomizer[]):com.intellij.diff.requests.DiffRequest
|
||||
|
||||
@@ -1675,14 +1675,6 @@ public final class DiffUtil {
|
||||
holder.putUserData(DiffUserDataKeys.NOTIFICATION_PROVIDERS, newProviders);
|
||||
}
|
||||
|
||||
public static void addNotificationIfAbsent(@NotNull DiffNotificationProvider provider, @NotNull UserDataHolder holder) {
|
||||
List<DiffNotificationProvider> providers = getNotificationProviders(holder);
|
||||
if(providers.contains(provider)) return;
|
||||
List<DiffNotificationProvider> newProviders = new ArrayList<>(providers);
|
||||
newProviders.add(provider);
|
||||
holder.putUserData(DiffUserDataKeys.NOTIFICATION_PROVIDERS, newProviders);
|
||||
}
|
||||
|
||||
public static @NotNull List<JComponent> createCustomNotifications(@Nullable DiffViewer viewer,
|
||||
@NotNull UserDataHolder context,
|
||||
@NotNull UserDataHolder request) {
|
||||
|
||||
@@ -153,8 +153,6 @@ merge.request.review.submit.action.tooltip=Submit merge request review
|
||||
|
||||
merge.request.details.changes.empty=No changes
|
||||
merge.request.diff.file.name=Diff for Merge Request !{0}
|
||||
merge.request.diff.empty.patch.warning=Comments are disabled for this change because the GitLab server returned an empty diff.\
|
||||
\ Typically, this means that the file is too big. If this is not the case, please report the issue via the Help menu.
|
||||
|
||||
# Merge request timeline
|
||||
merge.request.timeline.error=Failed to load timeline
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.progress.EmptyProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.coroutineToIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.UserDataHolderBase
|
||||
import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer
|
||||
import com.intellij.platform.util.coroutines.childScope
|
||||
@@ -27,15 +26,8 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
||||
/**
|
||||
* A viewmodel for an individual file diff in a merge request
|
||||
*/
|
||||
interface GitLabMergeRequestDiffChangeViewModel : AsyncDiffViewModel {
|
||||
val change: RefComparisonChange
|
||||
|
||||
companion object {
|
||||
internal val EMPTY_PATCH_KEY: Key<Boolean> = Key.create("GitLab.MergeRequest.Diff.Empty.Patch")
|
||||
}
|
||||
}
|
||||
|
||||
internal class GitLabMergeRequestDiffChangeViewModelImpl(
|
||||
@@ -50,20 +42,12 @@ internal class GitLabMergeRequestDiffChangeViewModelImpl(
|
||||
override val request: StateFlow<ComputedResult<DiffRequest>?> = computationStateFlow(reloadRequests.consumeAsFlow().withInitial(Unit)) {
|
||||
val changeDiffProducer = ChangeDiffRequestProducer.create(project, change.createVcsChange(project))
|
||||
?: error("Could not create diff producer from $change")
|
||||
coroutineToIndicator {
|
||||
val request = coroutineToIndicator {
|
||||
changeDiffProducer.process(UserDataHolderBase(), ProgressManager.getInstance().progressIndicator ?: EmptyProgressIndicator())
|
||||
}.apply {
|
||||
}
|
||||
request.apply {
|
||||
putUserData(RefComparisonChange.KEY, change)
|
||||
|
||||
val patchWithHistory = allChanges.patchesByChange[change]
|
||||
if (patchWithHistory != null) {
|
||||
if (patchWithHistory.patch.hunks.isNotEmpty()) {
|
||||
putUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER, patchWithHistory.getDiffComputer())
|
||||
}
|
||||
else {
|
||||
putUserData(GitLabMergeRequestDiffChangeViewModel.EMPTY_PATCH_KEY, true)
|
||||
}
|
||||
}
|
||||
putUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER, allChanges.patchesByChange[change]?.getDiffComputer())
|
||||
}
|
||||
}.stateIn(cs, SharingStarted.Lazily, null)
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@ import com.intellij.diff.DiffContext
|
||||
import com.intellij.diff.DiffExtension
|
||||
import com.intellij.diff.FrameDiffTool
|
||||
import com.intellij.diff.requests.DiffRequest
|
||||
import com.intellij.diff.tools.util.DiffNotifications
|
||||
import com.intellij.diff.tools.util.base.DiffViewerBase
|
||||
import com.intellij.diff.util.DiffUtil
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -39,14 +37,9 @@ import org.jetbrains.plugins.gitlab.mergerequest.ui.editor.GitLabMergeRequestDis
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.ui.editor.GitLabMergeRequestDraftNoteInlayRenderer
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.ui.editor.GitLabMergeRequestEditorMappedComponentModel
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.ui.editor.GitLabMergeRequestNewDiscussionInlayRenderer
|
||||
import org.jetbrains.plugins.gitlab.util.GitLabBundle
|
||||
import org.jetbrains.plugins.gitlab.util.GitLabStatistics
|
||||
|
||||
class GitLabMergeRequestDiffExtension : DiffExtension() {
|
||||
private val emptyDiffNotificationProvider by lazy {
|
||||
DiffNotifications.createNotificationProvider(GitLabBundle.message("merge.request.diff.empty.patch.warning"))
|
||||
}
|
||||
|
||||
override fun onViewerCreated(viewer: FrameDiffTool.DiffViewer, context: DiffContext, request: DiffRequest) {
|
||||
val project = context.project ?: return
|
||||
|
||||
@@ -55,10 +48,6 @@ class GitLabMergeRequestDiffExtension : DiffExtension() {
|
||||
val reviewVm = context.getUserData(GitLabMergeRequestDiffViewModel.KEY) ?: return
|
||||
val change = request.getUserData(RefComparisonChange.KEY) ?: return
|
||||
|
||||
if (request.getUserData(GitLabMergeRequestDiffChangeViewModel.EMPTY_PATCH_KEY) == true) {
|
||||
DiffUtil.addNotificationIfAbsent(emptyDiffNotificationProvider, request)
|
||||
}
|
||||
|
||||
project.service<InlaysController>().installInlays(reviewVm, change, viewer)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.intellij.collaboration.util.RefComparisonChange
|
||||
import com.intellij.collaboration.util.getOrNull
|
||||
import com.intellij.openapi.ListSelection
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.platform.util.coroutines.childScope
|
||||
@@ -38,9 +37,6 @@ import org.jetbrains.plugins.gitlab.mergerequest.ui.review.GitLabMergeRequestRev
|
||||
import kotlin.time.Duration.Companion.ZERO
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
|
||||
/**
|
||||
* A viewmodel for the merge request diff window capable of showing different file diffs
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface GitLabMergeRequestDiffViewModel : GitLabMergeRequestReviewViewModel, CodeReviewDiffProcessorViewModel<GitLabMergeRequestDiffChangeViewModel> {
|
||||
fun getViewModelFor(change: RefComparisonChange): Flow<GitLabMergeRequestDiffReviewViewModel?>
|
||||
@@ -50,8 +46,6 @@ interface GitLabMergeRequestDiffViewModel : GitLabMergeRequestReviewViewModel, C
|
||||
}
|
||||
}
|
||||
|
||||
private val LOG = logger<GitLabMergeRequestDiffProcessorViewModelImpl>()
|
||||
|
||||
internal class GitLabMergeRequestDiffProcessorViewModelImpl(
|
||||
private val project: Project,
|
||||
parentCs: CoroutineScope,
|
||||
@@ -106,16 +100,7 @@ internal class GitLabMergeRequestDiffProcessorViewModelImpl(
|
||||
changesFetchFlow
|
||||
.mapNotNull { it.getOrNull() }
|
||||
.mapScoped { changes ->
|
||||
val patchWithHistory = changes.patchesByChange[change]
|
||||
if (patchWithHistory == null) {
|
||||
LOG.warn("Could not find patch for change $change")
|
||||
return@mapScoped null
|
||||
}
|
||||
if (patchWithHistory.patch.hunks.isEmpty()) {
|
||||
LOG.warn("Empty patch for change $change")
|
||||
return@mapScoped null
|
||||
}
|
||||
createChangeVm(changes, change, patchWithHistory)
|
||||
changes.patchesByChange[change]?.let { createChangeVm(changes, change, it) }
|
||||
}.stateIn(cs, SharingStarted.WhileSubscribed(5.minutes, ZERO), null)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user