-
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. I'm making the signature of the callback take in an AIConfig object parameter, because we have function `clientConfigToAIConfig` within the editor pacakge: https://github.com/lastmile-ai/aiconfig/blob/c838856f36941b0796c8f12edcf846cc18ebdaa1/python/src/aiconfig/editor/client/src/shared/types.ts#L37 ## 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 ``` https://github.com/lastmile-ai/aiconfig/assets/151060367/123319cf-2e92-49e8-8f93-2d930a3b0ac7
- Loading branch information
1 parent
c838856
commit 5e04c5f
Showing
10 changed files
with
70 additions
and
11 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
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
import { Button } from "@mantine/core"; | ||
import { AIConfig } from "aiconfig"; | ||
import { memo, useContext, useState } from "react"; | ||
import AIConfigContext from "../../contexts/AIConfigContext"; | ||
import { clientConfigToAIConfig } from "../../shared/types"; | ||
|
||
type Props = { | ||
onDownload: (config: AIConfig) => Promise<void>; | ||
}; | ||
|
||
export default memo(function DownloadButton({ onDownload }: Props) { | ||
const { getState } = useContext(AIConfigContext); | ||
const [isDownloading, setIsDownloading] = useState<boolean>(false); | ||
|
||
const onClick = async () => { | ||
if (isDownloading) { | ||
return; | ||
} | ||
setIsDownloading(true); | ||
const config: AIConfig = clientConfigToAIConfig(getState()); | ||
await onDownload(config); | ||
setIsDownloading(false); | ||
}; | ||
|
||
return ( | ||
<Button | ||
loaderPosition="center" | ||
loading={isDownloading} | ||
onClick={onClick} | ||
size="xs" | ||
variant="filled" | ||
> | ||
Download | ||
</Button> | ||
); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"files": { | ||
"main.js": "/static/js/main.175446b3.js", | ||
"main.js": "/static/js/main.9eebadf6.js", | ||
"index.html": "/index.html", | ||
"main.175446b3.js.map": "/static/js/main.175446b3.js.map" | ||
"main.9eebadf6.js.map": "/static/js/main.9eebadf6.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/js/main.175446b3.js" | ||
"static/js/main.9eebadf6.js" | ||
] | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.175446b3.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.9eebadf6.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> |
1 change: 0 additions & 1 deletion
1
python/src/aiconfig/editor/server/static/static/js/main.175446b3.js.map
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
.../server/static/static/js/main.175446b3.js → .../server/static/static/js/main.9eebadf6.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
python/src/aiconfig/editor/server/static/static/js/main.9eebadf6.js.map
Large diffs are not rendered by default.
Oops, something went wrong.