Skip to content

Commit 67c2b5f

Browse files
committed
added new plugins to AdmService and extended logic of notification
1 parent 3dfe734 commit 67c2b5f

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

src/main/kotlin/com/vk/admstorm/AdmService.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import com.vk.admstorm.utils.extensions.unquote
1616
class AdmService(private var myProject: Project) {
1717
companion object {
1818
private val LOG = logger<AdmService>()
19-
val PLUGIN_ID = PluginId.getId("com.vk.admstorm")
19+
val ADM_PLUGIN_ID = PluginId.getId("com.vk.admstorm")
20+
val KPHPSTORM_PLUGIN_ID = PluginId.getId("com.vk.kphpstorm")
21+
val MODULITE_PLUGIN_ID = PluginId.getId("com.vk.modulite")
2022

2123
fun getInstance(project: Project) = project.service<AdmService>()
2224
}

src/main/kotlin/com/vk/admstorm/AdmStartupService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class AdmStartupService(private var project: Project) {
139139
}
140140

141141
private fun showWelcomeMessage() {
142-
val plugin = PluginManagerCore.getPlugin(AdmService.PLUGIN_ID) ?: return
142+
val plugin = PluginManagerCore.getPlugin(AdmService.ADM_PLUGIN_ID) ?: return
143143
RunOnceUtil.runOnceForApp("com.vk.admstorm.welcome.test.message.${plugin.version}") {
144144
AdmNotification(
145145
"""

src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt

+16-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.intellij.ide.plugins.InstalledPluginsState
55
import com.intellij.openapi.application.invokeLater
66
import com.intellij.openapi.diagnostic.Logger
77
import com.intellij.openapi.diagnostic.logger
8+
import com.intellij.openapi.extensions.PluginId
89
import com.intellij.openapi.fileTypes.ex.FileTypeChooser
910
import com.intellij.openapi.fileTypes.impl.AbstractFileType
1011
import com.intellij.openapi.options.ShowSettingsUtil
@@ -67,26 +68,36 @@ class AdmStormStartupActivity : ProjectActivity {
6768
Logger.setFactory(AdmStormLoggerFactory(sentry, defaultLoggerFactory))
6869
}
6970

71+
private fun hasNewVersion(pluginId : PluginId): Boolean {
72+
return InstalledPluginsState.getInstance().hasNewerVersion(pluginId)
73+
}
74+
7075
private fun checkUpdates(project: Project) {
71-
val hasNewerVersion = InstalledPluginsState.getInstance().hasNewerVersion(AdmService.PLUGIN_ID)
72-
if (!hasNewerVersion) {
76+
val hasAdmNewerVersion = hasNewVersion(AdmService.ADM_PLUGIN_ID)
77+
val hasKphpStormNewVersion = hasNewVersion(AdmService.KPHPSTORM_PLUGIN_ID)
78+
val hasModuliteNewVersion = hasNewVersion(AdmService.MODULITE_PLUGIN_ID)
79+
80+
if (!(hasAdmNewerVersion && hasModuliteNewVersion && hasKphpStormNewVersion)) {
7381
return
7482
}
7583

76-
AdmNotification("New version of the plugin is available")
84+
var updateNotification = AdmNotification("New version of the plugin is available")
7785
.withActions(
7886
AdmNotification.Action("Update") { _, _ ->
7987
invokeLater {
8088
ShowSettingsUtil.getInstance().showSettingsDialog(project, "Plugins")
8189
}
8290
}
8391
)
84-
.withActions(
92+
93+
if (hasAdmNewerVersion) {
94+
updateNotification = updateNotification.withActions(
8595
AdmNotification.Action("What's new") { _, _ ->
8696
val url = "https://vkcom.github.io/admstorm/whatsnew.html?server_name=${ServerNameProvider.name()}"
8797
BrowserUtil.browse(url)
8898
}
8999
)
90-
.show(project)
100+
}
101+
updateNotification.show(project)
91102
}
92103
}

src/main/kotlin/com/vk/admstorm/diagnostic/AdmStormLoggerFactory.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.vk.admstorm.services.SentryService
66

77
class AdmStormLoggerFactory(private val sentry: SentryService, private val factoryDelegate: Logger.Factory) : Logger.Factory {
88
override fun getLoggerInstance(category: String): Logger {
9-
if (category.contains(AdmService.PLUGIN_ID.idString)) {
9+
if (category.contains(AdmService.ADM_PLUGIN_ID.idString)) {
1010
return AdmStormLogger(sentry, factoryDelegate, category)
1111
}
1212

src/main/kotlin/com/vk/admstorm/services/SentryService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SentryService(project: Project) {
4545
return
4646
}
4747

48-
val plugin = PluginManagerCore.getPlugin(AdmService.PLUGIN_ID)
48+
val plugin = PluginManagerCore.getPlugin(AdmService.ADM_PLUGIN_ID)
4949
val application = ApplicationInfo.getInstance()
5050

5151
LOG.info("Sending errors to Sentry is enabled")

0 commit comments

Comments
 (0)