Skip to content

Commit 38b92f4

Browse files
authored
UX: Show a loading indicator when downloading a zip (#4833)
1 parent 88dbe85 commit 38b92f4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

frontend/src/components/project-menu/ProjectMenuCard.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ProjectMenuCardContextMenu } from "./project.menu-card-context-menu";
1212
import { ProjectMenuDetailsPlaceholder } from "./project-menu-details-placeholder";
1313
import { ProjectMenuDetails } from "./project-menu-details";
1414
import { downloadWorkspace } from "#/utils/download-workspace";
15+
import { LoadingSpinner } from "../modals/LoadingProject";
1516

1617
interface ProjectMenuCardProps {
1718
isConnectedToGitHub: boolean;
@@ -32,6 +33,7 @@ export function ProjectMenuCard({
3233
const [contextMenuIsOpen, setContextMenuIsOpen] = React.useState(false);
3334
const [connectToGitHubModalOpen, setConnectToGitHubModalOpen] =
3435
React.useState(false);
36+
const [working, setWorking] = React.useState(false);
3537

3638
const toggleMenuVisibility = () => {
3739
setContextMenuIsOpen((prev) => !prev);
@@ -63,15 +65,19 @@ Finally, open up a pull request using the GitHub API and the token in the GITHUB
6365
const handleDownloadWorkspace = () => {
6466
posthog.capture("download_workspace_button_clicked");
6567
try {
66-
downloadWorkspace();
68+
setWorking(true);
69+
downloadWorkspace().then(
70+
() => setWorking(false),
71+
() => setWorking(false),
72+
);
6773
} catch (error) {
6874
toast.error("Failed to download workspace");
6975
}
7076
};
7177

7278
return (
7379
<div className="px-4 py-[10px] w-[337px] rounded-xl border border-[#525252] flex justify-between items-center relative">
74-
{contextMenuIsOpen && (
80+
{!working && contextMenuIsOpen && (
7581
<ProjectMenuCardContextMenu
7682
isConnectedToGitHub={isConnectedToGitHub}
7783
onConnectToGitHub={() => setConnectToGitHubModalOpen(true)}
@@ -98,7 +104,11 @@ Finally, open up a pull request using the GitHub API and the token in the GITHUB
98104
onClick={toggleMenuVisibility}
99105
aria-label="Open project menu"
100106
>
101-
<EllipsisH width={36} height={36} />
107+
{working ? (
108+
<LoadingSpinner size="small" />
109+
) : (
110+
<EllipsisH width={36} height={36} />
111+
)}
102112
</button>
103113
{connectToGitHubModalOpen && (
104114
<ModalBackdrop onClose={() => setConnectToGitHubModalOpen(false)}>

0 commit comments

Comments
 (0)