Skip to content

Commit ebd5895

Browse files
committed
fix(chat-panel): support show file
1 parent 1a512b0 commit ebd5895

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

bricks/ai-portal/src/chat-panel/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class ChatPanel extends ReactNextElement implements ChatPanelProps {
121121
this.#ref.current?.send(payload);
122122
}
123123

124+
@method()
125+
showFile(file: FileInfo) {
126+
this.#ref.current?.showFile(file);
127+
}
128+
124129
render() {
125130
return (
126131
<ChatPanelComponent
@@ -146,6 +151,7 @@ interface ChatPanelRef {
146151
open: () => void;
147152
close: () => void;
148153
send: (payload: ChatPayload) => void;
154+
showFile: (file: FileInfo) => void;
149155
}
150156

151157
function LegacyChatPanelComponent(
@@ -275,6 +281,9 @@ function LegacyChatPanelComponent(
275281
send: (payload: ChatPayload) => {
276282
handleChatSubmit(payload);
277283
},
284+
showFile: (file: FileInfo) => {
285+
setActiveFile(file);
286+
},
278287
}),
279288
[handleChatSubmit]
280289
);

bricks/ai-portal/src/shared/FilePreview/FilePreview.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ initializeI18n(NS, locales);
2727

2828
export interface FilePreviewProps {
2929
file: FileInfo;
30+
fromModal?: boolean;
3031
}
3132

32-
export function FilePreview({ file }: FilePreviewProps) {
33+
export function FilePreview({ file, fromModal }: FilePreviewProps) {
3334
const { setActiveFile } = useContext(TaskContext);
3435
const { bytes, uri, mimeType, name } = file;
3536
const type = mimeType || getMimeTypeByFilename(name);
@@ -107,7 +108,7 @@ export function FilePreview({ file }: FilePreviewProps) {
107108
}, [file]);
108109

109110
return (
110-
<div className={styles.preview}>
111+
<div className={styles.preview} style={fromModal ? { zIndex: 1000 } : {}}>
111112
<div className={styles.header}>
112113
<div className={styles.title}>{file.name || t(K.UNTITLED)}</div>
113114
<div className={styles.toolbar}>

bricks/ai-portal/src/shared/FilePreview/ImagesPreview.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ import floatingStyles from "../FloatingButton.module.css";
1111

1212
export interface ImagesPreviewProps {
1313
images: ActiveImages;
14+
fromModal?: boolean;
1415
}
1516

16-
export function ImagesPreview({ images: { files, file } }: ImagesPreviewProps) {
17+
export function ImagesPreview({
18+
images: { files, file },
19+
fromModal,
20+
}: ImagesPreviewProps) {
1721
const [currentFile, setCurrentFile] = useState<FileInfo>(file);
1822
const { setActiveImages } = useContext(TaskContext);
1923

@@ -55,7 +59,7 @@ export function ImagesPreview({ images: { files, file } }: ImagesPreviewProps) {
5559
}, [go, setActiveImages]);
5660

5761
return (
58-
<div className={styles.preview}>
62+
<div className={styles.preview} style={fromModal ? { zIndex: 1000 } : {}}>
5963
<div className={styles.header}>
6064
<WrappedIconButton
6165
icon={ICON_DOWNLOAD}

0 commit comments

Comments
 (0)