mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move client code to core
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
This commit is contained in:
31
app/client/lib/download.js
Normal file
31
app/client/lib/download.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const G = require('../lib/browserGlobals').get('document');
|
||||
const dom = require('../lib/dom');
|
||||
|
||||
/**
|
||||
* Note about testing
|
||||
* It is difficult to test file downloads as Selenuim and javascript do not provide
|
||||
* an easy way to control native dialogs.
|
||||
* One approach would be to configure the test browser to automatically start the download and
|
||||
* save the file in a specific place. Then check that the file exists at that location.
|
||||
* Firefox documentation: http://kb.mozillazine.org/File_types_and_download_actions
|
||||
* Approach detailed here in java: https://www.seleniumeasy.com/selenium-tutorials/verify-file-after-downloading-using-webdriver-java
|
||||
*/
|
||||
|
||||
let _download = null;
|
||||
/**
|
||||
* Trigger a download on the file at the given url.
|
||||
* @param {String} href: The url of the download.
|
||||
*/
|
||||
function download(href) {
|
||||
if (!_download) {
|
||||
_download = dom('a', {
|
||||
style: 'position: absolute; top: 0; display: none',
|
||||
download: ''
|
||||
});
|
||||
G.document.body.appendChild(_download);
|
||||
}
|
||||
_download.setAttribute('href', href);
|
||||
_download.click();
|
||||
}
|
||||
|
||||
module.exports = download;
|
||||
Reference in New Issue
Block a user