Skip to content

Commit

Permalink
Add ai bot to settings and allow it to be enabled/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kateliu20 committed Sep 25, 2024
1 parent 5718b3d commit 8777666
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ class SkatePluginSettings : SimplePersistentStateComponent<SkatePluginSettings.S
state.codeOwnerFilePath = value
}

var isAiBotEnabled: Boolean
get() = state.isAiBotEnabled
set(value) {
state.isAiBotEnabled = value
}

class State : BaseState() {
var whatsNewFilePath by string()
var isWhatsNewEnabled by property(true)
Expand All @@ -137,5 +143,6 @@ class SkatePluginSettings : SimplePersistentStateComponent<SkatePluginSettings.S
var tracingEndpoint by string()
var codeOwnerFilePath by string()
var isCodeOwnerEnabled by property(true)
var isAiBotEnabled by property(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@
*/
package com.slack.sgp.intellij.aibot

import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
import com.slack.sgp.intellij.SkatePluginSettings
import javax.swing.JComponent
import slack.tooling.aibot.ChatPanel

class ChatBotToolWindow : ToolWindowFactory {

override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {

val settings = project.service<SkatePluginSettings>()
if (!settings.isAiBotEnabled) {
toolWindow.hide()
return
}

val contentFactory = ContentFactory.getInstance()
val content = contentFactory.createContent(createComposePanel(), "", false)
toolWindow.contentManager.addContent(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal class SkateConfigUI(
featureFlagSettings()
tracingSettings()
codeOwnerSettings()
aiBotSettings()
}

private fun Panel.whatsNewPanelSettings() {
Expand Down Expand Up @@ -192,4 +193,16 @@ internal class SkateConfigUI(
.apply { enabledCondition?.let { enabledIf(it) } }
}
}

private fun Panel.aiBotSettings() {
group(SkateBundle.message("skate.configuration.aiBot.title")) {
row {
checkBox(SkateBundle.message("skate.configuration.enableAiBot.description"))
.bindSelected(
getter = { settings.isAiBotEnabled },
setter = { settings.isAiBotEnabled = it },
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ skate.configuration.tracingEndpoint.error=API endpoint can't be empty
skate.configuration.codeOwner.title=Code Owner
skate.configuration.codeOwner.enabledDescription=Enable plugin to see team code ownership in status widget
skate.configuration.codeOwnerFile.title=File path
skate.configuration.codeOwnerFile.error=File path can't be empty
skate.configuration.codeOwnerFile.error=File path can't be empty
skate.configuration.aiBot.title=AI Chat Bot
skate.configuration.enableAiBot.description=Enable AI chatbot within the IDE

0 comments on commit 8777666

Please sign in to comment.