-
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.
Fix issue #5716: [Feature Request]: Add the button to jump to file ed…
…its view
- Loading branch information
1 parent
7a0488c
commit d1016c5
Showing
7 changed files
with
85 additions
and
8 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
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
41 changes: 41 additions & 0 deletions
41
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,41 @@ | ||
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; | ||
isDisabled?: boolean; | ||
} | ||
|
||
export function JumpToFileButton({ | ||
filePath, | ||
onClick, | ||
isDisabled = false, | ||
}: JumpToFileButtonProps) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ActionTooltip | ||
content={t(I18nKey.CHAT$JUMP_TO_FILE_TOOLTIP, { path: filePath })} | ||
side="top" | ||
> | ||
<button | ||
data-testid="jump-to-file-button" | ||
onClick={onClick} | ||
disabled={isDisabled} | ||
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", | ||
isDisabled && "opacity-50 cursor-not-allowed" | ||
)} | ||
> | ||
<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