diff --git a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx index ad80fa9ce..0818eb767 100644 --- a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx +++ b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx @@ -56,6 +56,7 @@ import { import { IconDeviceFloppy } from "@tabler/icons-react"; import CopyButton from "./CopyButton"; import AIConfigEditorThemeProvider from "../themes/AIConfigEditorThemeProvider"; +import DownloadButton from "./global/DownloadButton"; import ShareButton from "./global/ShareButton"; import PromptsContainer from "./prompt/PromptsContainer"; @@ -103,6 +104,7 @@ export type AIConfigCallbacks = { ) => Promise<{ aiconfig: AIConfig }>; clearOutputs: () => Promise<{ aiconfig: AIConfig }>; deletePrompt: (promptName: string) => Promise; + download?: () => Promise; getModels: (search: string) => Promise; getServerStatus?: () => Promise<{ status: "OK" | "ERROR" }>; logEventHandler?: (event: LogEvent, data?: LogEventData) => void; @@ -150,6 +152,23 @@ export default function AIConfigEditor({ const logEventHandler = callbacks?.logEventHandler; + const downloadCallback = callbacks?.download; + const onDownload = useCallback(async () => { + if (!downloadCallback) { + return; + } + try { + await downloadCallback(); + } catch (err: unknown) { + const message = (err as RequestCallbackError).message ?? null; + showNotification({ + title: "Error downloading AIConfig", + message, + color: "red", + }); + } + }, [downloadCallback]); + const shareCallback = callbacks?.share; const onShare = useCallback(async () => { if (!shareCallback) { @@ -962,6 +981,9 @@ export default function AIConfigEditor({ {!readOnly && ( + {downloadCallback && ( + + )} {shareCallback && } {onClearOutputs && ( + ); +}); diff --git a/python/src/aiconfig/editor/client/src/components/global/ShareButton.tsx b/python/src/aiconfig/editor/client/src/components/global/ShareButton.tsx index ba1947c92..6b324dfe3 100644 --- a/python/src/aiconfig/editor/client/src/components/global/ShareButton.tsx +++ b/python/src/aiconfig/editor/client/src/components/global/ShareButton.tsx @@ -38,7 +38,6 @@ export default memo(function ShareButton({ onShare }: Props) { loaderPosition="center" loading={isLoading} onClick={onClick} - p="xs" size="xs" variant="filled" >