drop.chapril.org-firefoxsend/app/pages/preview/index.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

const html = require('choo/html');
2018-07-31 20:09:18 +02:00
const titleSection = require('../../templates/title');
const downloadButton = require('../../templates/downloadButton');
const downloadedFiles = require('../../templates/uploadedFileList');
2018-07-31 20:09:18 +02:00
module.exports = function(state, emit) {
2018-08-08 00:40:17 +02:00
const fileInfo = state.fileInfo;
2018-08-01 00:19:18 +02:00
const trySendLink = html`
<a class="link link--action" href="/">
${state.translate('sendYourFilesLink')}
</a>`;
const cancelButton = html`
<button class="btn--cancel"
onclick=${cancel}
>
${state.translate('downloadCancel')}
</button>
`;
const bottomLink =
state.transfer.state === 'downloading' ? cancelButton : trySendLink;
2018-02-16 21:56:53 +01:00
return html`
<div class="page">
2018-07-31 20:09:18 +02:00
${titleSection(state)}
2018-08-08 00:40:17 +02:00
${downloadedFiles(fileInfo, state, emit)}
2018-07-31 20:09:18 +02:00
<div class="description">${state.translate('downloadMessage2')}</div>
${downloadButton(state, emit)}
2018-08-01 00:19:18 +02:00
${bottomLink}
2018-07-31 20:09:18 +02:00
</div>
`;
2018-08-01 00:19:18 +02:00
function cancel() {
if (state.transfer.state === 'downloading') {
emit('cancel');
}
}
};