From a05cc685155597eaf2377a4bfd0aef0c7c66cd5a Mon Sep 17 00:00:00 2001 From: Mykhailo Lytvyn Date: Wed, 15 May 2024 16:05:04 +0200 Subject: [PATCH] #1131 | Show bundled `What's New` tab with fallback to GitHub page --- .gitignore | 4 ++- CHANGELOG.md | 1 + build.gradle.kts | 11 +++++++ gradle.properties | 5 +-- .../hybris/startup/WhatsNewStartupActivity.kt | 32 +++++++++++++++++-- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4cfab3930..853882618 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,6 @@ /ccv2 -jflex-*.jar \ No newline at end of file +jflex-*.jar + +resources/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f13887585..fe64d2b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Other - Migrated to `IntelliJ Platform Gradle Plugin 2.beta2` [#1124](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1124) - Show once `CHANGELOG.md` in a new `What's New` tab once per version [#1125](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1125) +- Show bundled `What's New` tab with fallback to GitHub page [#1131](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1131) - Updated gradle wrapper to 8.7 [#1126](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1126) ## [2024.1.2] diff --git a/build.gradle.kts b/build.gradle.kts index 37c7b1c26..7dc08d021 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -120,6 +120,8 @@ val ccv2OpenApiTasks = ccv2OpenApiSpecs.mapIndexed { index, (taskName, schema, p if (index > 0) { val previousTaskName = ccv2OpenApiSpecs[index - 1].first dependsOn(previousTaskName) + } else { + dependsOn("copyChangelog") } } } @@ -182,6 +184,15 @@ intellijPlatform { } tasks { + val copyChangelog by registering(Copy::class) { + from("CHANGELOG.md") + into("resources") + } + + patchPluginXml { + dependsOn(copyChangelog) + } + val jvmArguments = mutableListOf().apply { add(properties("intellij.jvm.args").get()) diff --git a/gradle.properties b/gradle.properties index 34978930e..818cdadbd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ # ./gradlew wrapper --gradle-version 8.7 gradle.version=8.7 -org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false +#org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false # This is required because after upgrading to Gradle 5.1.1 the daemon runs out of memory during compilation with the # default value of 512m @@ -51,7 +51,8 @@ intellij.plugin.version=2024.1.3 intellij.plugin.since.build=241.14494.240 intellij.plugin.until.build=241.* -intellij.version=241.15989.150 +#intellij.version=241.15989.150 +intellij.version=2024.1.1 # Plugin Verifier integration -> https://github.com/JetBrains/intellij-plugin-verifier # https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl diff --git a/src/com/intellij/idea/plugin/hybris/startup/WhatsNewStartupActivity.kt b/src/com/intellij/idea/plugin/hybris/startup/WhatsNewStartupActivity.kt index 4b4354748..8ca067ace 100644 --- a/src/com/intellij/idea/plugin/hybris/startup/WhatsNewStartupActivity.kt +++ b/src/com/intellij/idea/plugin/hybris/startup/WhatsNewStartupActivity.kt @@ -22,10 +22,17 @@ import com.intellij.ide.util.RunOnceUtil import com.intellij.idea.plugin.hybris.settings.components.ProjectSettingsComponent import com.intellij.openapi.application.invokeLater import com.intellij.openapi.extensions.PluginId +import com.intellij.openapi.fileEditor.FileEditorManager +import com.intellij.openapi.fileEditor.TextEditorWithPreview import com.intellij.openapi.fileEditor.impl.HTMLEditorProvider +import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx import com.intellij.openapi.project.Project import com.intellij.openapi.startup.ProjectActivity +import com.intellij.openapi.util.io.StreamUtil +import com.intellij.testFramework.LightVirtualFile import com.intellij.ui.jcef.JBCefApp +import java.io.IOException +import java.nio.charset.StandardCharsets class WhatsNewStartupActivity : ProjectActivity { @@ -38,11 +45,30 @@ class WhatsNewStartupActivity : ProjectActivity { val version = pluginDescriptor.version RunOnceUtil.runOnceForProject(project, "sapCX_showWhatsNew_$version") { - val request = HTMLEditorProvider.Request.url("https://github.com/epam/sap-commerce-intellij-idea-plugin/blob/main/CHANGELOG.md#$version") + try { + val content = this.javaClass.getResourceAsStream("/CHANGELOG.md").use { html -> + html + ?.let { String(StreamUtil.readBytes(it), StandardCharsets.UTF_8) } + } ?: return@runOnceForProject - invokeLater { - HTMLEditorProvider.openEditor(project, "See What's New", request) + val lvf = LightVirtualFile("What's New in SAP Commerce Developers Toolset - ${version}").also { + it.putUserData(TextEditorWithPreview.DEFAULT_LAYOUT_FOR_FILE, TextEditorWithPreview.Layout.SHOW_PREVIEW) + it.setContent(null, content, true) + it.fileType = FileTypeManagerEx.getInstance().getFileTypeByExtension("md") + it.isWritable = false + } + + invokeLater { + FileEditorManager.getInstance(project).openFile(lvf, true, true) + } + } catch (e: IOException) { + val request = HTMLEditorProvider.Request.url("https://github.com/epam/sap-commerce-intellij-idea-plugin/blob/main/CHANGELOG.md#$version") + + invokeLater { + HTMLEditorProvider.openEditor(project, "What's New in SAP Commerce Developers Toolset - ${version}", request) + } } } } + }