Skip to content

Commit

Permalink
Adding 'Don't show again' button to ef core tools warning, resolves J…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nepp3r committed Mar 27, 2024
1 parent 1501339 commit 429bac0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ tasks {
}

patchPluginXml {
sinceBuild.set("233.0")
untilBuild.set("233.*")
sinceBuild.set("242.0")
untilBuild.set("242.*")
val latestChangelog = try {
changelog.getUnreleased()
} catch (_: MissingVersionException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jetbrains.rider.plugins.efcore.features.eftools

import com.intellij.notification.Notification
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.jetbrains.rider.plugins.efcore.EfCoreUiBundle
import com.jetbrains.rider.plugins.efcore.state.CommonOptionsStateService

class SuppressEfCoreToolsInstallation(private val notification : Notification) : AnAction(EfCoreUiBundle.message("action.install.ignore")) {
private val commonOptionsStateService by lazy { CommonOptionsStateService.getInstance() }
override fun actionPerformed(actionEvent: AnActionEvent) {
commonOptionsStateService.setProjectToolsInstallationSupressed(true)
this.notification.hideBalloon()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,32 @@ import com.jetbrains.rd.util.lifetime.Lifetime
import com.jetbrains.rider.plugins.efcore.EfCoreUiBundle
import com.jetbrains.rider.plugins.efcore.KnownNotificationGroups
import com.jetbrains.rider.plugins.efcore.features.eftools.InstallDotnetEfAction
import com.jetbrains.rider.plugins.efcore.features.eftools.SuppressEfCoreToolsInstallation
import com.jetbrains.rider.plugins.efcore.rd.RiderEfCoreModel
import com.jetbrains.rider.plugins.efcore.state.CommonOptionsStateService

@Suppress("UnstableApiUsage")
class EfCoreStartupListener : SolutionExtListener<RiderEfCoreModel> {
private val commonOptionsStateService by lazy { CommonOptionsStateService.getInstance() }
override fun extensionCreated(lifetime: Lifetime, session: ClientProjectSession, model: RiderEfCoreModel) {
model.onMissingEfCoreToolsDetected.set { _, unit ->
NotificationGroupManager
.getInstance()
.getNotificationGroup(KnownNotificationGroups.efCore)
.createNotification(
EfCoreUiBundle.message("notification.title.ef.core.tools.required"),
EfCoreUiBundle.message("notification.content.ef.core.tools.are.required.to.execute.this.action"),
NotificationType.WARNING
)
.addAction(InstallDotnetEfAction())
.notify(session.project)
if(!commonOptionsStateService.getProjectToolsInstallationSupressed()) {
model.onMissingEfCoreToolsDetected.set { _, unit ->
NotificationGroupManager
.getInstance()
.getNotificationGroup(KnownNotificationGroups.efCore)
.createNotification(
EfCoreUiBundle.message("notification.title.ef.core.tools.required"),
EfCoreUiBundle.message("notification.content.ef.core.tools.are.required.to.execute.this.action"),
NotificationType.WARNING
)
.addAction(InstallDotnetEfAction())
.apply{
addAction(SuppressEfCoreToolsInstallation(this))
}
.notify(session.project)

RdTask.fromResult(unit)
RdTask.fromResult(unit)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ class CommonOptionsState {
var solutionLevelOptions: MutableMap<String, String> = mutableMapOf()
var migrationsToStartupProjects: MutableMap<String, String> = mutableMapOf()
var startupToMigrationsProjects: MutableMap<String, String> = mutableMapOf()
var toolsInstallationSupressed: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@ class CommonOptionsStateService : PersistentStateComponent<CommonOptionsState> {
myState.solutionLevelOptions[MIGRATIONS_PROJECT_KEY] = migrationsProjectId.toString()
myState.solutionLevelOptions[STARTUP_PROJECT_KEY] = startupProjectId.toString()
}

fun setProjectToolsInstallationSupressed(newState : Boolean) {
myState.toolsInstallationSupressed = newState
}
fun getProjectToolsInstallationSupressed() : Boolean {
return myState.toolsInstallationSupressed
}
}
2 changes: 2 additions & 0 deletions src/rider/main/resources/messages/EfCoreUiBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ tab.ef.core.command=EF Core Command
#
# Install EF Core tools
action.install.text=Install
#Ignore notification of installation EF Core tools
action.install.ignore=Don't show again
ef.core.global.tools.have.been.successfully.installed=EF Core global tools have been successfully installed
progress.title.getting.dotnet.ef.version=Getting dotnet-ef version\u2026
notification.content.ef.core.tools.are.required.to.execute.this.action=To use EF Core in the IDE, install dotnet-ef as a global tool
Expand Down

0 comments on commit 429bac0

Please sign in to comment.