This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/add-image' into develop
- Loading branch information
Showing
15 changed files
with
357 additions
and
144 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
76 changes: 76 additions & 0 deletions
76
apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/components/FileContent/index.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,76 @@ | ||
import Icon from "@ant-design/icons" | ||
import { Button, Tooltip } from "antd" | ||
import { FC, useState } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { DownloadIcon, getFileIconByContentType } from "@illa-public/icon" | ||
import { GCS_OBJECT_TYPE } from "@illa-public/public-types" | ||
import { handleDownloadFiles } from "@/utils/drive/download" | ||
import { IFileContentProps } from "./interface" | ||
import { | ||
errorInfoStyle, | ||
fileCardContainerStyle, | ||
fileInfoStyle, | ||
fileNameStyle, | ||
fileTypeIconStyle, | ||
} from "./style" | ||
|
||
const FileContent: FC<IFileContentProps> = ({ | ||
contentType, | ||
fileName, | ||
downloadURL, | ||
}) => { | ||
const { t } = useTranslation() | ||
const [isExpired, setIsExpired] = useState(false) | ||
const handleDownload = (downloadURL: string, fileName: string) => { | ||
if (!downloadURL || !fileName) { | ||
return | ||
} | ||
const fileInfo = { | ||
name: fileName, | ||
downloadURL: downloadURL, | ||
} | ||
handleDownloadFiles([fileInfo]).catch((e) => { | ||
console.log("download", e) | ||
setIsExpired(true) | ||
}) | ||
} | ||
const contentBody = ( | ||
<div css={fileCardContainerStyle}> | ||
{getFileIconByContentType( | ||
GCS_OBJECT_TYPE.FILE, | ||
contentType, | ||
fileTypeIconStyle, | ||
)} | ||
<span css={fileInfoStyle}> | ||
<span css={fileNameStyle}>{fileName}</span> | ||
{isExpired && ( | ||
<span css={errorInfoStyle}>{t("The document has expired.")}</span> | ||
)} | ||
</span> | ||
</div> | ||
) | ||
return !downloadURL || !fileName || isExpired ? ( | ||
contentBody | ||
) : ( | ||
<Tooltip | ||
color="transparent" | ||
overlayInnerStyle={{ | ||
padding: 0, | ||
height: 24, | ||
width: 24, | ||
boxShadow: "none", | ||
}} | ||
title={ | ||
<Button | ||
icon={<Icon component={DownloadIcon} />} | ||
onClick={() => handleDownload(downloadURL, fileName)} | ||
size="small" | ||
/> | ||
} | ||
> | ||
{contentBody} | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default FileContent |
5 changes: 5 additions & 0 deletions
5
...gent/src/page/WorkSpace/AI/components/SyncMessageCard/components/FileContent/interface.ts
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,5 @@ | ||
export interface IFileContentProps { | ||
contentType: string | ||
fileName: string | ||
downloadURL: string | ||
} |
38 changes: 38 additions & 0 deletions
38
apps/agent/src/page/WorkSpace/AI/components/SyncMessageCard/components/FileContent/style.ts
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,38 @@ | ||
import { css } from "@emotion/react" | ||
import { getColor } from "@illa-public/color-scheme" | ||
|
||
export const fileCardContainerStyle = css` | ||
display: flex; | ||
padding: 8px 16px; | ||
align-items: center; | ||
gap: 4px; | ||
border-radius: 16px; | ||
border: 1px solid ${getColor("grayBlue", "08")}; | ||
background: #fafbfc; | ||
` | ||
|
||
export const fileTypeIconStyle = css` | ||
width: 24px; | ||
height: 30px; | ||
` | ||
|
||
export const fileNameStyle = css` | ||
color: ${getColor("grayBlue", "02")}; | ||
font-size: 14px; | ||
font-weight: 500; | ||
line-height: 22px; | ||
flex: 1; | ||
` | ||
|
||
export const fileInfoStyle = css` | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
` | ||
|
||
export const errorInfoStyle = css` | ||
color: ${getColor("red", "03")}; | ||
font-size: 12px; | ||
font-weight: 400; | ||
line-height: 18px; | ||
` |
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
44 changes: 44 additions & 0 deletions
44
apps/agent/src/page/WorkSpace/AI/components/UserMessage/FileContent/index.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,44 @@ | ||
import { FC } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { getFileIconByContentType } from "@illa-public/icon" | ||
import { GCS_OBJECT_TYPE, IKnowledgeFile } from "@illa-public/public-types" | ||
import { | ||
errorInfoStyle, | ||
fileInfoStyle, | ||
fileItemStyle, | ||
fileNameStyle, | ||
fileTypeIconStyle, | ||
iconContainerStyle, | ||
} from "./style" | ||
|
||
interface IFileContentProps | ||
extends Pick<IKnowledgeFile, "contentType" | "fileName"> { | ||
isExpired?: boolean | ||
} | ||
|
||
const FileContent: FC<IFileContentProps> = ({ | ||
contentType, | ||
fileName, | ||
isExpired, | ||
}) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<div css={fileItemStyle}> | ||
<span css={iconContainerStyle}> | ||
{getFileIconByContentType( | ||
GCS_OBJECT_TYPE.FILE, | ||
contentType, | ||
fileTypeIconStyle, | ||
)} | ||
</span> | ||
<span css={fileInfoStyle}> | ||
<span css={fileNameStyle}>{fileName}</span> | ||
{isExpired && ( | ||
<span css={errorInfoStyle}>{t("The document has expired.")}</span> | ||
)} | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
export default FileContent |
Oops, something went wrong.