feat(frontend): add logo to source when integration (#2899)

# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
This commit is contained in:
Antoine Dewez 2024-07-22 17:51:22 +02:00 committed by GitHub
parent 61bb7b2e02
commit feb084ee39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import React, { useEffect, useState } from "react";
import { useChatInput } from "@/app/chat/[chatId]/components/ActionsBar/components/ChatInput/hooks/useChatInput";
import { useChat } from "@/app/chat/[chatId]/hooks/useChat";
import { useChatApi } from "@/lib/api/chat/useChatApi";
import { Integration } from "@/lib/api/sync/types";
import { CopyButton } from "@/lib/components/ui/CopyButton";
import { Icon } from "@/lib/components/ui/Icon/Icon";
import { Source } from "@/lib/types/MessageMetadata";
@ -66,6 +67,8 @@ export const MessageRow = ({
file_url: source.source_url,
citations: [source.citation],
selected: false,
integration: source.integration as Integration,
integration_link: source.integration_link,
});
}

View File

@ -1,5 +1,7 @@
import Image from "next/image";
import { useState } from "react";
import { useSync } from "@/lib/api/sync/useSync";
import { Icon } from "@/lib/components/ui/Icon/Icon";
import Tooltip from "@/lib/components/ui/Tooltip/Tooltip";
@ -17,6 +19,7 @@ export const SourceCitations = ({ sourceFile }: SourceProps): JSX.Element => {
const [isCitationModalOpened, setIsCitationModalOpened] =
useState<boolean>(false);
const [citationIndex, setCitationIndex] = useState<number>(0);
const { integrationIconUrls } = useSync();
return (
<div>
@ -29,17 +32,30 @@ export const SourceCitations = ({ sourceFile }: SourceProps): JSX.Element => {
>
<a
onClick={(event) => event.stopPropagation()}
href={sourceFile.file_url}
href={
sourceFile.integration_link
? sourceFile.integration_link
: sourceFile.file_url
}
target="_blank"
rel="noopener noreferrer"
>
<div className={styles.source_header}>
<span className={styles.filename}>{sourceFile.filename}</span>
{sourceFile.integration ? (
<Image
src={integrationIconUrls[sourceFile.integration]}
width="16"
height="16"
alt="integration_icon"
/>
) : (
<Icon
name="externLink"
size="small"
color={hovered ? "primary" : "black"}
/>
)}
</div>
</a>
</div>

View File

@ -1,6 +1,10 @@
import { Integration } from "@/lib/api/sync/types";
export interface SourceFile {
filename: string;
file_url: string;
citations: string[];
selected: boolean;
integration?: Integration;
integration_link?: string;
}

View File

@ -5,4 +5,6 @@ export interface Source {
source_url: string;
type: string;
thoughts: string;
integration?: string;
integration_link?: string;
}