2017-08-24 21:54:02 +00:00
|
|
|
const html = require('choo/html');
|
|
|
|
const assets = require('../../common/assets');
|
|
|
|
const { bytes } = require('../utils');
|
|
|
|
|
2018-01-24 18:23:13 +00:00
|
|
|
module.exports = function(state, pageAction) {
|
2017-08-24 21:54:02 +00:00
|
|
|
const fileInfo = state.fileInfo;
|
2018-01-31 23:47:34 +00:00
|
|
|
|
2017-08-31 16:43:36 +00:00
|
|
|
const size = fileInfo.size
|
|
|
|
? state.translate('downloadFileSize', { size: bytes(fileInfo.size) })
|
|
|
|
: '';
|
2018-01-24 18:23:13 +00:00
|
|
|
|
2018-02-01 00:26:59 +00:00
|
|
|
const title = fileInfo.name
|
2017-08-31 16:43:36 +00:00
|
|
|
? state.translate('downloadFileName', { filename: fileInfo.name })
|
2018-02-01 00:26:59 +00:00
|
|
|
: state.translate('downloadFileTitle');
|
2018-01-31 23:47:34 +00:00
|
|
|
|
2018-02-01 00:26:59 +00:00
|
|
|
const info = html`
|
|
|
|
<div id="dl-file"
|
|
|
|
data-nonce="${fileInfo.nonce}"
|
|
|
|
data-requires-password="${fileInfo.requiresPassword}"></div>`;
|
2018-01-31 23:47:34 +00:00
|
|
|
if (!pageAction) {
|
2018-02-01 00:26:59 +00:00
|
|
|
return info;
|
2018-01-31 23:47:34 +00:00
|
|
|
}
|
2017-08-24 21:54:02 +00:00
|
|
|
const div = html`
|
|
|
|
<div id="page-one">
|
|
|
|
<div id="download">
|
|
|
|
<div id="download-page-one">
|
|
|
|
<div class="title">
|
2018-02-01 00:26:59 +00:00
|
|
|
<span>${title}</span>
|
|
|
|
<span id="dl-filesize">${' ' + size}</span>
|
2017-08-24 21:54:02 +00:00
|
|
|
</div>
|
|
|
|
<div class="description">${state.translate('downloadMessage')}</div>
|
2018-01-24 18:23:13 +00:00
|
|
|
<img
|
|
|
|
src="${assets.get('illustration_download.svg')}"
|
|
|
|
id="download-img"
|
2018-01-31 23:47:34 +00:00
|
|
|
title="${state.translate('downloadAltText')}"/>
|
2018-01-24 18:23:13 +00:00
|
|
|
${pageAction}
|
2017-08-24 21:54:02 +00:00
|
|
|
</div>
|
|
|
|
<a class="send-new" href="/">${state.translate('sendYourFilesLink')}</a>
|
|
|
|
</div>
|
2018-02-01 00:26:59 +00:00
|
|
|
${info}
|
2017-08-24 21:54:02 +00:00
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
return div;
|
|
|
|
};
|