From fb052e9793bfc028037257e7d6aad49c15074f1e Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 2 May 2025 20:33:21 +0100 Subject: [PATCH] Implement topic ai changes --- .../TopicDetail/PredefinedActionGroup.tsx | 20 +++++++------- .../TopicDetail/PredefinedActions.tsx | 2 +- src/components/TopicDetail/TopicDetail.tsx | 9 ++++++- src/components/TopicDetail/TopicDetailAI.tsx | 26 ++++++++++++++++++- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/components/TopicDetail/PredefinedActionGroup.tsx b/src/components/TopicDetail/PredefinedActionGroup.tsx index 0b95d476c..07f06bf16 100644 --- a/src/components/TopicDetail/PredefinedActionGroup.tsx +++ b/src/components/TopicDetail/PredefinedActionGroup.tsx @@ -2,19 +2,19 @@ import type { LucideIcon } from 'lucide-react'; import { useState, useRef } from 'react'; import { useOutsideClick } from '../../hooks/use-outside-click'; import { - type PredefinedMessageType, + type PredefinedActionType, PredefinedActionButton, } from './PredefinedActions'; -type PredefinedMessageGroupProps = { +type PredefinedActionGroupProps = { label: string; icon: LucideIcon; - messages: PredefinedMessageType[]; - onSelect: (message: PredefinedMessageType) => void; + actions: PredefinedActionType[]; + onSelect: (action: PredefinedActionType) => void; }; -export function PredefinedActionGroup(props: PredefinedMessageGroupProps) { - const { label, icon: Icon, messages, onSelect } = props; +export function PredefinedActionGroup(props: PredefinedActionGroupProps) { + const { label, icon: Icon, actions, onSelect } = props; const [isOpen, setIsOpen] = useState(false); const containerRef = useRef(null); @@ -34,14 +34,14 @@ export function PredefinedActionGroup(props: PredefinedMessageGroupProps) { {isOpen && (
- {messages.map((m) => { + {actions.map((action) => { return ( { - onSelect(m); + onSelect(action); setIsOpen(false); }} /> diff --git a/src/components/TopicDetail/PredefinedActions.tsx b/src/components/TopicDetail/PredefinedActions.tsx index 0639527c4..665ec9268 100644 --- a/src/components/TopicDetail/PredefinedActions.tsx +++ b/src/components/TopicDetail/PredefinedActions.tsx @@ -79,7 +79,7 @@ export function PredefinedActions(props: PredefinedActionsProps) { key={action.label} label={action.label} icon={action.icon} - messages={action.children} + actions={action.children} onSelect={onSelect} /> ); diff --git a/src/components/TopicDetail/TopicDetail.tsx b/src/components/TopicDetail/TopicDetail.tsx index 09864c27f..a58fcab87 100644 --- a/src/components/TopicDetail/TopicDetail.tsx +++ b/src/components/TopicDetail/TopicDetail.tsx @@ -25,7 +25,10 @@ import { Ban, FileText, HeartHandshake, Star, X } from 'lucide-react'; import { getUrlParams, parseUrl } from '../../lib/browser'; import { Spinner } from '../ReactIcons/Spinner'; import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; -import { resourceTitleFromId, type AllowedRoadmapRenderer } from '../../lib/roadmap.ts'; +import { + resourceTitleFromId, + type AllowedRoadmapRenderer, +} from '../../lib/roadmap.ts'; import { lockBodyScroll } from '../../lib/dom.ts'; import { TopicDetailLink } from './TopicDetailLink.tsx'; import { ResourceListSeparator } from './ResourceListSeparator.tsx'; @@ -441,6 +444,10 @@ export function TopicDetail(props: TopicDetailProps) { aiChatHistory={aiChatHistory} setAiChatHistory={setAiChatHistory} onUpgrade={() => setShowUpgradeModal(true)} + onLogin={() => { + handleClose(); + showLoginPopup(); + }} /> )} diff --git a/src/components/TopicDetail/TopicDetailAI.tsx b/src/components/TopicDetail/TopicDetailAI.tsx index f9862b974..ad9b93c29 100644 --- a/src/components/TopicDetail/TopicDetailAI.tsx +++ b/src/components/TopicDetail/TopicDetailAI.tsx @@ -40,6 +40,7 @@ type TopicDetailAIProps = { setAiChatHistory: (history: AIChatHistoryType[]) => void; onUpgrade: () => void; + onLogin: () => void; }; export function TopicDetailAI(props: TopicDetailAIProps) { @@ -50,6 +51,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) { resourceType, topicId, onUpgrade, + onLogin, } = props; const textareaRef = useRef(null); @@ -307,6 +309,11 @@ export function TopicDetailAI(props: TopicDetailAIProps) {