RUST-15869 Show Contact Support ini non-commercial RustRover

The button points to our special Slack workspace


(cherry picked from commit f4d0287d609ee4d90b14319166cbb324950e5afa)

IJ-CR-148887

GitOrigin-RevId: 05dc103d1cd15dd085812dfa21a961322aad9228
This commit is contained in:
Vladislav Beskrovny
2024-11-15 13:19:28 +00:00
committed by intellij-monorepo-bot
parent 3c2549301a
commit 5c7fd97b96
2 changed files with 20 additions and 4 deletions
@@ -62,6 +62,13 @@ interface ExternalProductResourceUrls {
val technicalSupportUrl: ((description: String) -> Url)?
get() = null
/**
* Used just like [technicalSupportUrl] if the product is activated with a free (non-commercial) license
*/
@get:ApiStatus.Internal
val freeTechnicalSupportUrl: ((description: String) -> Url)?
get() = null
/**
* Returns an instance which will be used to submit feedback about the product via the "Submit Feedback" action.
* If this function returns `null`, the action won't be available.
@@ -10,22 +10,31 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAware
import com.intellij.platform.ide.customization.ExternalProductResourceUrls
import com.intellij.util.PlatformUtils
import com.intellij.util.Url
import kotlinx.coroutines.launch
internal class TechnicalSupportAction : AnAction(), DumbAware {
override fun update(e: AnActionEvent) {
e.presentation.setEnabledAndVisible(ExternalProductResourceUrls.getInstance().technicalSupportUrl != null &&
PlatformUtils.isCommercialEdition() &&
!service<ConsentOptionsProvider>().isActivatedWithFreeLicense)
e.presentation.setEnabledAndVisible(getTechnicalSupportUrl() != null)
}
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun actionPerformed(e: AnActionEvent) {
val url = ExternalProductResourceUrls.getInstance().technicalSupportUrl ?: return
val url = getTechnicalSupportUrl() ?: return
val project = e.project
service<ReportFeedbackService>().coroutineScope.launch {
BrowserUtil.browse(url(SendFeedbackAction.getDescription(project)).toExternalForm(), project)
}
}
private fun getTechnicalSupportUrl(): ((description: String) -> Url)? {
val isPaid = PlatformUtils.isCommercialEdition() &&
!service<ConsentOptionsProvider>().isActivatedWithFreeLicense
return if (isPaid) {
ExternalProductResourceUrls.getInstance().technicalSupportUrl
} else {
ExternalProductResourceUrls.getInstance().freeTechnicalSupportUrl
}
}
}