added account to capabilities

This commit is contained in:
Danny Coates 2018-09-14 13:58:19 -07:00
parent 3a162d47c5
commit 942457b357
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
5 changed files with 14 additions and 9 deletions

View File

@ -64,6 +64,7 @@ export default async function capabilities() {
const polyStreams = nativeStreams ? false : polyfillStreams(); const polyStreams = nativeStreams ? false : polyfillStreams();
return { return {
account: typeof localStorage !== 'undefined',
crypto, crypto,
streamUpload: nativeStreams || polyStreams, streamUpload: nativeStreams || polyStreams,
streamDownload: streamDownload:

View File

@ -1,7 +1,7 @@
const html = require('choo/html'); const html = require('choo/html');
module.exports = function(state) { module.exports = function(state) {
if (state.user.loggedIn) { if (state.user.loggedIn || !state.capabilities.account) {
return null; return null;
} }
return html` return html`

View File

@ -1,10 +1,16 @@
const html = require('choo/html'); const html = require('choo/html');
module.exports = function(state, emit) { module.exports = function(state, emit) {
if (!state.capabilities.account) {
return null;
}
const user = state.user; const user = state.user;
const menu = user.loggedIn const menu = user.loggedIn
? html` ? html`
<ul class="account_dropdown"> <ul
class="account_dropdown"
onblur=${hideMenu}
tabindex="-1">
<li class="account_dropdown__text"> <li class="account_dropdown__text">
${user.email} ${user.email}
</li> </li>
@ -15,9 +21,10 @@ module.exports = function(state, emit) {
</li> </li>
</ul>` </ul>`
: html` : html`
<ul class="account_dropdown" <ul
tabindex="-1" class="account_dropdown"
> onblur=${hideMenu}
tabindex="-1">
<li> <li>
<a class="account_dropdown__link" onclick=${login}>${state.translate( <a class="account_dropdown__link" onclick=${login}>${state.translate(
'signInMenuOption' 'signInMenuOption'
@ -55,12 +62,9 @@ module.exports = function(state, emit) {
emit('logout'); emit('logout');
} }
//the onblur trick makes links unclickable wtf
/*
function hideMenu(event) { function hideMenu(event) {
event.stopPropagation(); event.stopPropagation();
const dropdown = document.querySelector('.account_dropdown'); const dropdown = document.querySelector('.account_dropdown');
dropdown.classList.remove('visible'); dropdown.classList.remove('visible');
} }
*/
}; };

View File

@ -7,6 +7,7 @@ module.exports = function(req) {
const locale = req.language || 'en-US'; const locale = req.language || 'en-US';
return { return {
locale, locale,
capabilities: { account: true },
translate: locales.getTranslator(locale), translate: locales.getTranslator(locale),
title: 'Firefox Send', title: 'Firefox Send',
description: description:

View File

@ -157,7 +157,6 @@ const web = {
} }
}, },
'extract-loader', 'extract-loader',
'babel-loader',
'./build/fluent_loader' './build/fluent_loader'
] ]
}, },