-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add jump-to-file button in chat messages (simplified version)
- Add JumpToFileButton component that reuses existing ActionTooltip - Update ChatMessage to show file button when filePath is available - Add filePath to Message type and set it in chat slice - Add translations for the jump-to-file tooltip
- Loading branch information
1 parent
62fbe4c
commit 814cc4f
Showing
6 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
frontend/src/components/shared/buttons/jump-to-file-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { VscGoToFile } from "react-icons/vsc"; | ||
import { I18nKey } from "#/i18n/declaration"; | ||
import { ActionTooltip } from "#/components/shared/action-tooltip"; | ||
import { cn } from "#/utils/utils"; | ||
|
||
interface JumpToFileButtonProps { | ||
filePath: string; | ||
onClick: () => void; | ||
} | ||
|
||
export function JumpToFileButton({ filePath, onClick }: JumpToFileButtonProps) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ActionTooltip content={t(I18nKey.CHAT$JUMP_TO_FILE_TOOLTIP, { path: filePath })} side="top"> | ||
Check failure on line 17 in frontend/src/components/shared/buttons/jump-to-file-button.tsx
|
||
<button | ||
type="button" | ||
data-testid="jump-to-file-button" | ||
onClick={onClick} | ||
className={cn( | ||
"absolute top-2 right-12 p-2 rounded-lg", | ||
"text-neutral-400 hover:text-neutral-200 hover:bg-neutral-700", | ||
"transition-colors duration-200" | ||
)} | ||
> | ||
<VscGoToFile size={16} /> | ||
</button> | ||
</ActionTooltip> | ||
); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ type Message = { | |
pending?: boolean; | ||
translationID?: string; | ||
eventID?: number; | ||
filePath?: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters