Skip to content
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

Adding 'Don't show again' button to ef core tools warning, resolves #213 #216

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ tasks {
}

patchPluginXml {
<<<<<<< HEAD
sinceBuild.set(sinceProductVersion)
=======
sinceBuild.set("242.0")
untilBuild.set("242.*")
>>>>>>> 429bac0 (Adding 'Don't show again' button to ef core tools warning, resolves #213)
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.toolsInstallationSupressed = true
notification.hideBalloon()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,30 @@ 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.toolsInstallationSupressed) {
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())
.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
@@ -1,8 +1,6 @@
package com.jetbrains.rider.plugins.efcore.state

import com.intellij.openapi.components.*
import com.intellij.openapi.project.Project
import com.jetbrains.rider.plugins.efcore.features.shared.services.PreferredProjectsManager
import java.util.*

@Service
Expand Down Expand Up @@ -59,4 +57,10 @@ class CommonOptionsStateService : PersistentStateComponent<CommonOptionsState> {
myState.solutionLevelOptions[MIGRATIONS_PROJECT_KEY] = migrationsProjectId.toString()
myState.solutionLevelOptions[STARTUP_PROJECT_KEY] = startupProjectId.toString()
}

var toolsInstallationSupressed : Boolean
get() = myState.toolsInstallationSupressed
set(value : Boolean){
myState.toolsInstallationSupressed = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ tab.ef.core.command=EF Core Command
#
# Install EF Core tools
action.install.text=Install
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