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

Skate Plugin Settings Checkbox Enhancement #448

Closed
wants to merge 32 commits into from

Conversation

kateliu20
Copy link
Contributor

@kateliu20 kateliu20 commented Jul 7, 2023

This is just a simple enhancement for the Skate Plugin Settings UI Panel.

Before, the checkbox text would not wrap and would require users to scroll horizontally:
Screenshot 2023-07-07 at 4 23 09 PM

Now, the text is wrapped:
Screenshot 2023-07-07 at 4 22 44 PM

This is just a simple enhancement for user readability, and I added documentation to the SkateConfigUI.kt file as well.

Katherine Liu and others added 30 commits June 27, 2023 14:50
…ange_log_parser

# Conflicts:
#	skate-plugin/src/test/kotlin/com/slack/sgp/intellij/ChangeLogParserTest.kt
@github-actions
Copy link

github-actions bot commented Jul 7, 2023

  1. In build.gradle.kts, instead of using plugins.set(listOf(/* Plugin Dependencies */ )), you can use plugins { id("org.intellij.plugins.markdown") } to add the Markdown plugin dependency.
-intellij {
+intellij {
   version.set("2022.2.5")
   type.set("IC") // Target IDE Platform
 
   plugins.add("org.intellij.plugins.markdown")
 }
  1. In ChangelogParser.kt, you can remove the empty line before the comment to improve code readability.
     .trimEnd()
-
 // If the changelog substring is blank, set it as null
 // If the previous entry equals to the latest entry, or if no date is found,
 // use the previous entry date as the latest date instead of the current date.
  1. In SkateService.kt, you can remove the unused import statement import com.slack.sgp.intellij.ui.WhatsNewPanelFactory.

  2. In SkateService.kt, you can remove the commented out code and the unused variable changeLogString.

  3. In SkateService.kt, you can remove the unused import statement import com.intellij.openapi.util.Disposer.

  4. In SkateService.kt, you can move the creation of parentDisposable outside the invokeLater block to improve code readability.

   toolWindowManager.invokeLater {
     val toolWindow =
       toolWindowManager.registerToolWindow("skate-whats-new") {
         stripeTitle = Supplier { "What's New in Slack!" }
         anchor = ToolWindowAnchor.RIGHT
       }
-    val parentDisposable = Disposer.newDisposable()
+
+    // The Disposable is necessary to prevent a substantial memory leak while working with
+    // MarkdownJCEFHtmlPanel
+    val parentDisposable = Disposer.newDisposable()
+
     WhatsNewPanelFactory()
-      .createToolWindowContent(toolWindow, project, changeLogString, parentDisposable)
+      .createToolWindowContent(toolWindow, project, changeLogString, parentDisposable)
 
     toolWindow.show()
   }
  1. In SkateConfigUI.kt, you can remove the unused import statement import java.io.File.

  2. In SkateConfigUI.kt, you can use HTML tags to format the description text in the checkbox label.

   row(SkateBundle.message("skate.configuration.enableWhatsNew.title")) {
-    checkBox(SkateBundle.message("skate.configuration.enableWhatsNew.description"))
+    checkBox(
+        "<html>${SkateBundle.message("skate.configuration.enableWhatsNew.description")}</html>"
+      )
       .bindSelected(
         getter = { settings.isWhatsNewEnabled },
         setter = { settings.isWhatsNewEnabled = it }
  1. In WhatsNewPanelFactory.kt, you can remove the unused import statements import org.intellij.lang.annotations.Language and import javax.swing.JComponent.

  2. In WhatsNewPanelFactory.kt, you can remove the commented out code for parsing the changelog and the unused variable parsedChangelog.

  3. In WhatsNewPanelFactory.kt, you can remove the Disposer.register(parentDisposable, panel) line as it's not necessary.

  4. In WhatsNewPanelFactory.kt, you can remove the runReadAction block and directly pass markdownFileString to MarkdownUtil.generateMarkdownHtml.

   val file = LightVirtualFile("changelog.md", markdownFileString)
 
   val panel = MarkdownJCEFHtmlPanel(project, file)
-  Disposer.register(parentDisposable, panel)
-  val html = runReadAction {
-    MarkdownUtil.generateMarkdownHtml(file, markdownFileString, project)
-  }
+  val html = MarkdownUtil.generateMarkdownHtml(file, markdownFileString, project)
 
   panel.setHtml(html, 0)
   return panel.component
  1. In plugin.xml, you can add the dependency on the Markdown plugin by adding <depends>org.intellij.plugins.markdown</depends>.
   <!-- Product and plugin compatibility requirements.
        Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
   <depends>com.intellij.modules.platform</depends>
+  <depends>org.intellij.plugins.markdown</depends>
 
   <!-- Extension points defined by the plugin.
        Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
  1. In skateBundle.properties, you can use <br> tag to add a line break in the description text.
 skate.configuration.enableWhatsNew.description=If enabled, shows the What's New Panel if there are new changes detected <br> in a specified changelog file.

Overall, the code looks good and the suggested changes are mainly for improving code readability and removing unused code.

@kateliu20 kateliu20 closed this Jul 7, 2023
@kateliu20 kateliu20 deleted the kl/skate_settings_checkbox_enhancement branch July 7, 2023 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant