Skip to content

Commit

Permalink
feat(ui): make panel works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 3, 2023
1 parent 00cc025 commit cf21878
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
21 changes: 21 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/AutoDevNotifications.kt
@@ -0,0 +1,21 @@
package cc.unitmesh.devti

import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationGroup
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.project.Project

object AutoDevNotifications {
private fun createNotificationGroup(): NotificationGroup? {
return NotificationGroupManager.getInstance().getNotificationGroup("AutoDev.notification.group")
}

fun notify(project: Project, msg: String) {
val notification = createNotificationGroup()?.createNotification(msg, NotificationType.INFORMATION)
// notification!!.addAction(NotificationAction.createSimple(msg) {
// notification.expire();
// })
notification?.notify(project)
}
}
@@ -1,9 +1,15 @@
package cc.unitmesh.devti.gui.chat.message

import cc.unitmesh.devti.AutoDevBundle
import cc.unitmesh.devti.AutoDevIcons
import cc.unitmesh.devti.AutoDevNotifications
import cc.unitmesh.devti.gui.block.CompletableMessage
import com.intellij.ide.HelpTooltip
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.project.DumbAwareToggleAction
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.util.Key
import javax.swing.Icon


Expand Down Expand Up @@ -33,12 +39,13 @@ abstract class AutoDevRateMessageAction : DumbAwareToggleAction() {
}

override fun setSelected(e: AnActionEvent, state: Boolean) {
val project = e.project ?: ProjectManager.getInstance().openProjects.firstOrNull() ?: return
AutoDevNotifications.notify(project, AutoDevBundle.message("tooltip.thanks"))

val message = getMessage(e) ?: return
val completableMessage = getMessage(e)
message.rating = if (isSelected(e)) ChatMessageRating.None else getReaction()
}


class Like : AutoDevRateMessageAction() {
override fun getReaction(): ChatMessageRating = ChatMessageRating.Like

Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/META-INF/autodev-core.xml
Expand Up @@ -5,6 +5,9 @@
<depends>Git4Idea</depends>

<extensions defaultExtensionNs="com.intellij">
<notificationGroup id="AutoDev.notification.group" displayType="STICKY_BALLOON" bundle="messages.AutoDevBundle"
key="notification.group.name"/>

<applicationConfigurable parentId="tools" instance="cc.unitmesh.devti.settings.AutoDevSettingsConfigurable"
id="cc.unitmesh.devti.settings.AutoDevSettingsConfigurable"
displayName="AutoDev"/>
Expand Down Expand Up @@ -230,8 +233,8 @@
<group id="AutoDev.ToolWindow.Message.Toolbar.Assistant">
<action id="AIAssistant.ToolWindow.Message.Like"
class="cc.unitmesh.devti.gui.chat.message.AutoDevRateMessageAction$Like"/>
<action id="AIAssistant.ToolWindow.Message.Dislike"
class="cc.unitmesh.devti.gui.chat.message.AutoDevRateMessageAction$Dislike"/>
<!-- <action id="AIAssistant.ToolWindow.Message.Dislike"-->
<!-- class="cc.unitmesh.devti.gui.chat.message.AutoDevRateMessageAction$Dislike"/>-->
</group>

</actions>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages/AutoDevBundle.properties
Expand Up @@ -34,4 +34,5 @@ intentions.crud.new.family.name=AutoCrud with this
intentions.chat.selected.code.name=Chat with this code
intentions.chat.selected.fragment.name=Chat with {0} fragment
intentions.chat.selected.element.name=Chat with ''{0}'' {1}
chat.too.long.user.message=Message has is {0} tokens, it's too looooooooooooooooooong
chat.too.long.user.message=Message has is {0} tokens, it's too looooooooooooooooooong
tooltip.thanks=Thanks for like, but we don't support this

0 comments on commit cf21878

Please sign in to comment.