-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download Button [1/n]: Setup UI on the editor client
If the download callback is defined (not for local editor or VSCode, but will be for Gradio), then we display it and use the loading state to disable you from clicking on the button ## Test Plan Rebase onto #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 ```
- Loading branch information
1 parent
90f0f99
commit 4d347e4
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
python/src/aiconfig/editor/client/src/components/global/DownloadButton.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,32 @@ | ||
import { Button } from "@mantine/core"; | ||
import { memo, useState } from "react"; | ||
|
||
type Props = { | ||
onDownload: () => Promise<string | void>; | ||
}; | ||
|
||
export default memo(function ShareButton({ onDownload }: Props) { | ||
const [isDownloading, setIsDownloading] = useState<boolean>(false); | ||
|
||
const onClick = async () => { | ||
if (isDownloading) { | ||
return; | ||
} | ||
setIsDownloading(true); | ||
await onDownload(); | ||
setIsDownloading(false); | ||
}; | ||
|
||
return ( | ||
<Button | ||
loaderPosition="center" | ||
loading={isDownloading} | ||
onClick={onClick} | ||
p="xs" | ||
size="xs" | ||
variant="filled" | ||
> | ||
Download | ||
</Button> | ||
); | ||
}); |