diff --git a/platform/platform-api/src/com/intellij/platform/ide/customization/ExternalProductResourceUrls.kt b/platform/platform-api/src/com/intellij/platform/ide/customization/ExternalProductResourceUrls.kt index 4c6b2eb81797..9c72f0de96fe 100644 --- a/platform/platform-api/src/com/intellij/platform/ide/customization/ExternalProductResourceUrls.kt +++ b/platform/platform-api/src/com/intellij/platform/ide/customization/ExternalProductResourceUrls.kt @@ -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. diff --git a/platform/platform-impl/src/com/intellij/ide/actions/TechnicalSupportAction.kt b/platform/platform-impl/src/com/intellij/ide/actions/TechnicalSupportAction.kt index 9c4d09b68919..ba5020c140f8 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/TechnicalSupportAction.kt +++ b/platform/platform-impl/src/com/intellij/ide/actions/TechnicalSupportAction.kt @@ -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().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().coroutineScope.launch { BrowserUtil.browse(url(SendFeedbackAction.getDescription(project)).toExternalForm(), project) } } + + private fun getTechnicalSupportUrl(): ((description: String) -> Url)? { + val isPaid = PlatformUtils.isCommercialEdition() && + !service().isActivatedWithFreeLicense + return if (isPaid) { + ExternalProductResourceUrls.getInstance().technicalSupportUrl + } else { + ExternalProductResourceUrls.getInstance().freeTechnicalSupportUrl + } + } }