From dece0969c220934ef2e83bb1631d20826f0bd9a3 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Wed, 23 Jan 2019 15:10:09 -0800 Subject: [PATCH] added download link to tile --- app/ui/archiveTile.js | 82 +++++++++++++++++++++++-------------------- app/ui/header.js | 4 +-- app/utils.js | 11 +++++- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/app/ui/archiveTile.js b/app/ui/archiveTile.js index 5d0202d1..22461970 100644 --- a/app/ui/archiveTile.js +++ b/app/ui/archiveTile.js @@ -4,11 +4,11 @@ const html = require('choo/html'); const raw = require('choo/html/raw'); const assets = require('../../common/assets'); const { - browserName, bytes, copyToClipboard, list, percent, + platform, timeLeft } = require('../utils'); const expiryOptions = require('./expiryOptions'); @@ -44,9 +44,9 @@ function password(state) { ${ - translate('fileCount', { - num: archive.manifest.files.length - }) - }${translate('fileCount', { + num: archive.manifest.files.length + })} - ${ - list( - archive.manifest.files.map(f => fileInfo(f)), - 'list-reset h-full' - ) - } + ${list( + archive.manifest.files.map(f => fileInfo(f)), + 'list-reset h-full' + )} `; } @@ -150,15 +146,14 @@ function archiveDetails(translate, archive) { module.exports = function(state, emit, archive) { const copyOrShare = - browserName() !== 'android-app' + platform() !== 'android' ? html` ` : html` @@ -169,6 +164,19 @@ module.exports = function(state, emit, archive) { Share `; + const dl = + platform() === 'web' + ? html` + + ${state.translate('downloadButtonLabel')} + + ` + : html` +
+ `; return html` ${archiveDetails(state.translate, archive)}
- ${copyOrShare} +
+ ${dl} + ${copyOrShare} +
`; function copy(event) { @@ -219,15 +230,13 @@ module.exports = function(state, emit, archive) { module.exports.wip = function(state, emit) { return html` - ${ - list( - Array.from(state.archive.files) - .reverse() - .map(f => fileInfo(f, remove(f))), - 'list-reset overflow-y-scroll px-4 bg-blue-lightest md:h-full md:max-h-half-screen', - 'bg-white px-2 mt-3 border border-grey-light rounded' - ) - } + ${list( + Array.from(state.archive.files) + .reverse() + .map(f => fileInfo(f, remove(f))), + 'list-reset overflow-y-scroll px-4 bg-blue-lightest md:h-full md:max-h-half-screen', + 'bg-white px-2 mt-3 border border-grey-light rounded' + )}
- ${ - state.translate('addFilesButton') - } + + ${state.translate('addFilesButton')}
${state.translate('totalSize', { size: bytes(state.archive.size) })} @@ -347,13 +355,11 @@ module.exports.empty = function(state, emit) { return html` { + if (e.target.tagName !== 'LABEL') { + document.getElementById('file-upload').click(); } - }" + }}" >

diff --git a/app/utils.js b/app/utils.js index 58ac64e9..4933a808 100644 --- a/app/utils.js +++ b/app/utils.js @@ -1,3 +1,4 @@ +/* global Android */ const html = require('choo/html'); const b64 = require('base64-js'); @@ -240,6 +241,13 @@ function timeLeft(milliseconds) { return null; } +function platform() { + if (typeof Android === 'object') { + return 'android'; + } + return 'web'; +} + module.exports = { fadeOut, delay, @@ -257,5 +265,6 @@ module.exports = { streamToArrayBuffer, list, secondsToL10nId, - timeLeft + timeLeft, + platform };