You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feedback.tsx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import type { SlashCommandHandler } from './types'
  2. import React from 'react'
  3. import { RiFeedbackLine } from '@remixicon/react'
  4. import i18n from '@/i18n-config/i18next-config'
  5. import { registerCommands, unregisterCommands } from './command-bus'
  6. // Feedback command dependency types
  7. type FeedbackDeps = Record<string, never>
  8. /**
  9. * Feedback command - Opens GitHub feedback discussions
  10. */
  11. export const feedbackCommand: SlashCommandHandler<FeedbackDeps> = {
  12. name: 'feedback',
  13. description: 'Open feedback discussions',
  14. async search(args: string, locale: string = 'en') {
  15. return [{
  16. id: 'feedback',
  17. title: i18n.t('common.userProfile.communityFeedback', { lng: locale }),
  18. description: i18n.t('app.gotoAnything.actions.feedbackDesc', { lng: locale }) || 'Open community feedback discussions',
  19. type: 'command' as const,
  20. icon: (
  21. <div className='flex h-6 w-6 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg'>
  22. <RiFeedbackLine className='h-4 w-4 text-text-tertiary' />
  23. </div>
  24. ),
  25. data: { command: 'navigation.feedback', args: { url: 'https://github.com/langgenius/dify/discussions/categories/feedbacks' } },
  26. }]
  27. },
  28. register(_deps: FeedbackDeps) {
  29. registerCommands({
  30. 'navigation.feedback': async (args) => {
  31. const url = args?.url || 'https://github.com/langgenius/dify/discussions/categories/feedbacks'
  32. window.open(url, '_blank', 'noopener,noreferrer')
  33. },
  34. })
  35. },
  36. unregister() {
  37. unregisterCommands(['navigation.feedback'])
  38. },
  39. }