Skip to content

Commit b4bf11d

Browse files
committed
add loading icon when upload artifact content
1 parent ab9f538 commit b4bf11d

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

app/components/artifact.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ExportIcon from "../icons/share.svg";
77
import CopyIcon from "../icons/copy.svg";
88
import DownloadIcon from "../icons/download.svg";
99
import GithubIcon from "../icons/github.svg";
10+
import LoadingButtonIcon from "../icons/loading.svg";
1011
import Locale from "../locales";
1112
import { Modal, showToast } from "./ui-lib";
1213
import { copyToClipboard, downloadAs } from "../utils";
@@ -83,6 +84,7 @@ export function ArtifactShareButton({
8384
style?: any;
8485
fileName?: string;
8586
}) {
87+
const [loading, setLoading] = useState(false);
8688
const [name, setName] = useState(id);
8789
const [show, setShow] = useState(false);
8890
const shareUrl = useMemo(
@@ -110,16 +112,19 @@ export function ArtifactShareButton({
110112
<>
111113
<div className="window-action-button" style={style}>
112114
<IconButton
113-
icon={<ExportIcon />}
115+
icon={loading ? <LoadingButtonIcon /> : <ExportIcon />}
114116
bordered
115117
title={Locale.Export.Artifact.Title}
116118
onClick={() => {
117-
upload(getCode()).then((res) => {
118-
if (res?.id) {
119-
setShow(true);
120-
setName(res?.id);
121-
}
122-
});
119+
setLoading(true);
120+
upload(getCode())
121+
.then((res) => {
122+
if (res?.id) {
123+
setShow(true);
124+
setName(res?.id);
125+
}
126+
})
127+
.finally(() => setLoading(false));
123128
}}
124129
/>
125130
</div>

0 commit comments

Comments
 (0)