From 26593262991ad8ac67ae8956385a21ea561a8b4c Mon Sep 17 00:00:00 2001 From: "Rossdan Craig rossdan@lastmileai.dev" <> Date: Fri, 26 Jan 2024 16:58:40 -0500 Subject: [PATCH] Share Button [7/n]: Display loading UI Created a separate component for the shareButton to manage the `isLoading` state and show that in the UI ## Test Plan Rebase on then do: https://github.com/lastmile-ai/aiconfig/pull/1045 Go to `aiconfig/python/src/aiconfig/editor/client` and run this command: ``` rm -rf node_modules && yarn && yarn build ``` Then go to `aiconfig` dir and run this command: ``` aiconfig_path =./cookbooks/Gradio/huggingface.aiconfig.json parsers_path=./cookbooks/Gradio/hf_model_parsers.py aiconfig edit --aiconfig-path=$aiconfig_path --server-port=8080 --server-mode=debug_servers --parsers-module-path=$parsers_path ``` No Error Testing https://github.com/lastmile-ai/aiconfig/assets/151060367/0c177c59-54b8-4d04-adfa-aea6d78f5f07 Error Testing https://github.com/lastmile-ai/aiconfig/assets/151060367/1abcce37-8ba4-4513-b826-ea0f9d7bb720 --- .../client/src/components/AIConfigEditor.tsx | 19 ++----- .../src/components/global/ShareButton.tsx | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 python/src/aiconfig/editor/client/src/components/global/ShareButton.tsx diff --git a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx index 1100653c0..cc3440295 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 ShareButton from "./global/ShareButton"; import PromptsContainer from "./prompt/PromptsContainer"; type Props = { @@ -155,10 +156,8 @@ export default function AIConfigEditor({ return; } try { - // TODO: While uploading, show a loader state for share button const { share_url: shareUrl } = await shareCallback(); - // TODO: display the shareUrl in a dialog - // console.log("Share URL: ", shareUrl); + return shareUrl; } catch (err: unknown) { const message = (err as RequestCallbackError).message ?? null; showNotification({ @@ -962,19 +961,7 @@ export default function AIConfigEditor({ {!readOnly && ( - {shareCallback && ( - - - - )} - + {shareCallback && } {onClearOutputs && ( + ); + + const tooltipMessage: string = isLoading + ? "Generating share link..." + : "Create a link to share your AIConfig!"; + return ( + +
{button}
+
+ ); +});