Extract the "Untrusted Project" editor notification banner to platform-impl

So it can be reused by other subsystems, which are not related to external systems.

GitOrigin-RevId: 3a1699b8a7c41e819dc9c943ff496e3abff3a99b
This commit is contained in:
Kirill Likhodedov
2021-03-09 10:06:59 +00:00
committed by intellij-monorepo-bot
parent e7b85fb763
commit 8bb693d143
4 changed files with 32 additions and 22 deletions
@@ -17,10 +17,6 @@ unlinked.project.notification.help.text=\
untrusted.project.notification.execution.error={0} project is untrusted, so its task cannot be executed.
untrusted.project.notification.trust.link=Trust project\u2026
untrusted.project.notification.read.more.link=Read more
untrusted.project.notification.description=Safe mode, limited functionality. Trust the project to access full IDE functionality.
untrusted.project.notification.trust.button=Trust Project
untrusted.project.notification.distrust.button=Stay in Safe Mode
untrusted.project.notification.title=Trust {0} {1,choice,1#Project|1<Projects}?
@@ -1,17 +1,14 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.externalSystem.service.project
import com.intellij.ide.impl.TRUSTED_PROJECTS_HELP_TOPIC
import com.intellij.ide.impl.TrustChangeNotifier
import com.intellij.ide.impl.TrustedProjectsStatistics
import com.intellij.ide.impl.isTrusted
import com.intellij.ide.IdeBundle
import com.intellij.ide.impl.*
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.externalSystem.ExternalSystemManager
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
import com.intellij.openapi.externalSystem.model.ProjectSystemId
import com.intellij.openapi.externalSystem.service.project.ExternalResolverIsSafe.executesTrustedCodeOnly
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil.confirmLoadingUntrustedProject
import com.intellij.openapi.fileEditor.FileEditor
@@ -35,20 +32,12 @@ class UntrustedProjectNotificationProvider : EditorNotifications.Provider<Editor
if (providers.isEmpty()) {
return null
}
return EditorNotificationPanel(fileEditor).apply {
text = ExternalSystemBundle.message("untrusted.project.notification.description")
createActionLabel(ExternalSystemBundle.message("untrusted.project.notification.trust.link"), {
TrustedProjectsStatistics.TRUST_PROJECT_FROM_BANNER.log()
if (confirmLoadingUntrustedProject(project, providers.map { it.systemId })) {
for (provider in providers) {
provider.loadAllLinkedProjects(project)
}
return UntrustedProjectEditorNotificationPanel(fileEditor) {
if (confirmLoadingUntrustedProject(project, providers.map { it.systemId })) {
for (provider in providers) {
provider.loadAllLinkedProjects(project)
}
}, false)
createActionLabel(ExternalSystemBundle.message("untrusted.project.notification.read.more.link"), {
TrustedProjectsStatistics.READ_MORE_FROM_BANNER.log()
HelpManager.getInstance().invokeHelp(TRUSTED_PROJECTS_HELP_TOPIC)
}, false)
}
}
}
@@ -2520,6 +2520,9 @@ split.with.chooser.move.tab=Press %s to open%s
split.with.chooser.duplicate.tab=, %s to duplicate
split.with.chooser.switch.tab=Use %s to go to the next splitter
untrusted.project.notification.description=Safe mode, limited functionality. Trust the project to access full IDE functionality.
untrusted.project.notification.trust.link=Trust project\u2026
untrusted.project.notification.read.more.link=Read more
# {0} stands for something like github.com/JetBrains
untrusted.project.warning.trust.host.checkbox=Trust {0}
@@ -0,0 +1,22 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.impl
import com.intellij.ide.IdeBundle
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.help.HelpManager
import com.intellij.ui.EditorNotificationPanel
class UntrustedProjectEditorNotificationPanel(fileEditor: FileEditor,
onTrustProjectLinkClicked: () -> Unit) : EditorNotificationPanel(fileEditor) {
init {
text = IdeBundle.message("untrusted.project.notification.description")
createActionLabel(IdeBundle.message("untrusted.project.notification.trust.link"), {
TrustedProjectsStatistics.TRUST_PROJECT_FROM_BANNER.log()
onTrustProjectLinkClicked()
}, false)
createActionLabel(IdeBundle.message("untrusted.project.notification.read.more.link"), {
TrustedProjectsStatistics.READ_MORE_FROM_BANNER.log()
HelpManager.getInstance().invokeHelp(TRUSTED_PROJECTS_HELP_TOPIC)
}, false)
}
}