From 077522a9114bd38c9d65b2babfa39e3efe4fb571 Mon Sep 17 00:00:00 2001 From: Boris Trombert Date: Mon, 19 Aug 2024 16:33:49 +0200 Subject: [PATCH 1/2] ai react for me button for posts Changelog: added --- .../components/assets/icon_react_for_me.tsx | 26 +++++++++++++++++++ .../src/plugins/ai/components/post_menu.tsx | 16 ++++++++++++ webapp/platform/client/src/client4.ts | 6 +++++ 3 files changed, 48 insertions(+) create mode 100644 webapp/channels/src/plugins/ai/components/assets/icon_react_for_me.tsx diff --git a/webapp/channels/src/plugins/ai/components/assets/icon_react_for_me.tsx b/webapp/channels/src/plugins/ai/components/assets/icon_react_for_me.tsx new file mode 100644 index 0000000000..6e47f8bc0e --- /dev/null +++ b/webapp/channels/src/plugins/ai/components/assets/icon_react_for_me.tsx @@ -0,0 +1,26 @@ +import React from 'react'; + +import Svg from '../svg'; + +const IconReactForMe = () => ( + + + + + +); + +export default IconReactForMe; diff --git a/webapp/channels/src/plugins/ai/components/post_menu.tsx b/webapp/channels/src/plugins/ai/components/post_menu.tsx index abcdc5a01d..5b410ecccf 100644 --- a/webapp/channels/src/plugins/ai/components/post_menu.tsx +++ b/webapp/channels/src/plugins/ai/components/post_menu.tsx @@ -14,6 +14,7 @@ import {handleEvent} from 'actions/websocket_actions'; import type {GlobalState} from 'types/store'; import IconAI from './assets/icon_ai'; +import IconReactForMe from './assets/icon_react_for_me'; import IconThreadSummarization from './assets/icon_thread_summarization'; import {DropdownBotSelector} from './bot_slector'; import DotMenu, {DropdownMenu, DropdownMenuItem} from './dot_menu'; @@ -60,6 +61,14 @@ const PostMenu = (props: Props) => { } }; + const reactForMe = async (postId: string) => { + try { + await Client4.doReaction(postId); + } catch (error) { + console.error('Error react post:', error); + } + }; + // if (!isBasicsLicensed) { // return null; // } @@ -95,6 +104,13 @@ const PostMenu = (props: Props) => { + reactForMe(post.id)}> + + + {/* */} diff --git a/webapp/platform/client/src/client4.ts b/webapp/platform/client/src/client4.ts index e8854eda08..5a48f86243 100644 --- a/webapp/platform/client/src/client4.ts +++ b/webapp/platform/client/src/client4.ts @@ -4875,6 +4875,12 @@ export default class Client4 { return this.doFetch(url, {method: 'post'}); } + async doReaction(postId: string) { + const url = `${this.getPostRoute(postId)}/react`; + + return this.doFetch(url, {method: 'post'}); + } + async doStopGenerating(postId: string) { const url = `${this.getPostRoute(postId)}/stop`; From 3d42f6e4753ba82a36ec2b9871c3e3e65a1a21ac Mon Sep 17 00:00:00 2001 From: Boris Trombert Date: Mon, 19 Aug 2024 16:41:25 +0200 Subject: [PATCH 2/2] add traductions --- webapp/channels/src/i18n/de.json | 1 + webapp/channels/src/i18n/en.json | 5 +++-- webapp/channels/src/i18n/es.json | 1 + webapp/channels/src/i18n/fr.json | 1 + webapp/channels/src/i18n/it.json | 1 + webapp/channels/src/plugins/ai/components/post_menu.tsx | 2 +- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/webapp/channels/src/i18n/de.json b/webapp/channels/src/i18n/de.json index f1bf5a15b8..e53ad0cfc0 100644 --- a/webapp/channels/src/i18n/de.json +++ b/webapp/channels/src/i18n/de.json @@ -2694,6 +2694,7 @@ "air_gapped_modal.title": "Testschlüssel anfordern", "ai.summarizeThread" : "Thread zusammenfassen", "ai.actions" : "KI-Aktionen", + "ai.react_for_me": "Reagiere für mich", "alert_banner.tooltipCloseBtn": "Schliessen", "analytics.chart.loading": "Lade...", "analytics.chart.meaningful": "Nicht genügend Daten für eine aussagekräftige Darstellung.", diff --git a/webapp/channels/src/i18n/en.json b/webapp/channels/src/i18n/en.json index cd809ce1fa..bcb4f2e026 100644 --- a/webapp/channels/src/i18n/en.json +++ b/webapp/channels/src/i18n/en.json @@ -2778,8 +2778,9 @@ "air_gapped_modal.close": "Close", "air_gapped_modal.description": "To start your trial, please visit {link} and request a trial key.", "air_gapped_modal.title": "Request a trial key", - "ai.summarizeThread" : "Summarize thread", - "ai.actions" : "AI Actions", + "ai.summarizeThread": "Summarize thread", + "ai.actions": "AI Actions", + "ai.react_for_me": "React for me", "admin.webserverModeUncompressedDescription": "The kChat server will serve static files uncompressed.", "alert_banner.tooltipCloseBtn": "Close", "analytics.chart.loading": "Loading...", diff --git a/webapp/channels/src/i18n/es.json b/webapp/channels/src/i18n/es.json index 21a352ce13..17529f207b 100644 --- a/webapp/channels/src/i18n/es.json +++ b/webapp/channels/src/i18n/es.json @@ -2481,6 +2481,7 @@ "admin_settings.save_unsaved_changes": "Por favor, guarde los cambios primero", "ai.summarizeThread" : "Resumir hilo", "ai.actions" : "Acciones IA", + "ai.react_for_me": "Reacciona por mí", "analytics.chart.loading": "Cargando...", "analytics.chart.meaningful": "No hay suficiente data para tener una representación significativa.", "analytics.system.activeUsers": "Usuarios Activos con Mensajes", diff --git a/webapp/channels/src/i18n/fr.json b/webapp/channels/src/i18n/fr.json index b2a32f8f9b..3f54f6cb5f 100644 --- a/webapp/channels/src/i18n/fr.json +++ b/webapp/channels/src/i18n/fr.json @@ -2431,6 +2431,7 @@ "air_gapped_modal.title": "Demander une clé d’essai", "ai.summarizeThread" : "Résumer le fil de discussion", "ai.actions" : "Actions IA", + "ai.react_for_me": "Réagir pour moi", "alert_banner.tooltipCloseBtn": "Fermer", "analytics.chart.loading": "Chargement…", "analytics.chart.meaningful": "Pas assez de données pour afficher une représentation pertinente.", diff --git a/webapp/channels/src/i18n/it.json b/webapp/channels/src/i18n/it.json index b1869da4d8..2e0ddced23 100644 --- a/webapp/channels/src/i18n/it.json +++ b/webapp/channels/src/i18n/it.json @@ -1848,6 +1848,7 @@ "analytics.chart.meaningful": "Dati insufficienti per una rappresentazione significativa.", "ai.summarizeThread" : "Riassumi il thread", "ai.actions" : "Azioni IA", + "ai.react_for_me": "Reagisci per me", "analytics.system.activeUsers": "Utenti attivi con post", "analytics.system.channelTypes": "Tipi di canale", "analytics.system.dailyActiveUsers": "Utenti attivi quotidianamente", diff --git a/webapp/channels/src/plugins/ai/components/post_menu.tsx b/webapp/channels/src/plugins/ai/components/post_menu.tsx index 5b410ecccf..c58c692c78 100644 --- a/webapp/channels/src/plugins/ai/components/post_menu.tsx +++ b/webapp/channels/src/plugins/ai/components/post_menu.tsx @@ -107,7 +107,7 @@ const PostMenu = (props: Props) => { reactForMe(post.id)}>