-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zip downloading: added modal for successfully downloading zips in game #10255
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,6 +318,17 @@ export class ScriptManagerDialog extends data.Component<ScriptManagerDialogProps | |
this.setState({ sortedAsc: !sortedAsc }); | ||
} | ||
|
||
renderDownloadDialog(fileName: string) { | ||
return <> | ||
<div> | ||
{lf("Your projects were zipped and downloaded successfully!")} | ||
<br /> | ||
<br /> | ||
{lf("Look for the file {0} on your computer. It might have a number before the .zip if you've downloaded before.", fileName)} | ||
</div> | ||
</>; | ||
} | ||
|
||
handleDownloadAsync = async () => { | ||
pxt.tickEvent("scriptmanager.downloadZip", undefined, { interactiveConsent: true }); | ||
|
||
|
@@ -424,11 +435,25 @@ export class ScriptManagerDialog extends data.Component<ScriptManagerDialogProps | |
|
||
const zipName = `makecode-${targetNickname}-project-download.zip` | ||
|
||
pxt.BrowserUtils.browserDownloadDataUri(datauri, zipName); | ||
|
||
this.setState({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the reordering of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I should move this back, thanks for pointing that out. I think I was reordering stuff to better understand how everything interacted and moving it didn't change anything. The |
||
download: null | ||
}); | ||
|
||
pxt.BrowserUtils.browserDownloadDataUri(datauri, zipName); | ||
if (pxt.BrowserUtils.isInGame()) { | ||
const downloadJsx = this.renderDownloadDialog(zipName); | ||
|
||
setTimeout(async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the timeout waiting for the download to finish? 2 seconds may not be enough time for someone with a whole bunch of projects and very slow internet (though not sure how likely that is). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is. That's a good point. I don't really want to increase the time for it off the bat, though, because if it's too long and the notification shows up way after downloading then it feels even more disjoint. This is not my favorite solution, but I included the timeout because I couldn't find an event that could tell us that the user stopped interacting with the filesystem/download unfortunately. No timeout was even worse because the modal would show up even before the filesystem modal would show up. |
||
await core.confirmAsync({ | ||
header: lf("Projects Downloaded..."), | ||
jsx: downloadJsx, | ||
hasCloseIcon: true, | ||
hideAgree: true, | ||
className: 'zipdownloaddialog', | ||
}) | ||
}, 2000); | ||
} | ||
} | ||
|
||
handleDownloadProgressClose = () => { | ||
|
@@ -529,7 +554,7 @@ export class ScriptManagerDialog extends data.Component<ScriptManagerDialogProps | |
} | ||
headerActions.push(<sui.Button key="delete" icon="trash" className="icon red" | ||
text={lf("Delete")} textClass="landscape only" title={lf("Delete Project")} onClick={this.handleDelete} />); | ||
if (numSelected > 1) { | ||
if (numSelected > 1 && pxt.BrowserUtils.hasFileAccess()) { | ||
headerActions.push(<sui.Button key="download-zip" icon="download" className="icon" | ||
text={lf("Download Zip")} textClass="landscape only" title={lf("Download Zip")} onClick={this.handleDownloadAsync} />); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least when I've done this, I get a popup where I can choose the location and name for the file (both in the browser and when running dev Minecraft build on Windows pointing to your uploaded target). I'm wondering if we really need this additional string, or if we can just say it was downloaded successfully and leave it at that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what happens for me, too. I added the extra string because it just felt a bit bare to me with just one line, but I can remove the extra stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer concise language here. This needs to be translated to lot of languages and number system might be different. Just say "Your projects successfully downloaded as a zip"