From cdc15596dfac4c6792aea8c46855e4e159a5e5f9 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Fri, 7 Sep 2018 10:53:40 -0700 Subject: [PATCH] stubbed in modal dialog --- app/fileManager.js | 6 +++-- app/main.css | 40 +++++++++++++++-------------- app/main.js | 1 + app/routes/index.js | 8 ++++++ app/serviceWorker.js | 2 +- app/templates/expireInfo/index.js | 5 ++-- app/templates/modal/index.js | 15 +++++++++++ app/templates/modal/modal.css | 22 ++++++++++++++++ app/templates/okDialog/index.js | 13 ++++++++++ app/templates/okDialog/okDialog.css | 11 ++++++++ public/locales/en-US/send.ftl | 1 + 11 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 app/templates/modal/index.js create mode 100644 app/templates/modal/modal.css create mode 100644 app/templates/okDialog/index.js create mode 100644 app/templates/okDialog/okDialog.css diff --git a/app/fileManager.js b/app/fileManager.js index 97846f88..634722c3 100644 --- a/app/fileManager.js +++ b/app/fileManager.js @@ -6,6 +6,7 @@ import * as metrics from './metrics'; import Archive from './archive'; import { bytes } from './utils'; import { prepareWrapKey } from './fxa'; +import okDialog from './templates/okDialog'; export default function(state, emitter) { let lastRender = 0; @@ -97,7 +98,7 @@ export default function(state, emitter) { try { state.archive.addFiles(files, maxSize); } catch (e) { - alert( + state.modal = okDialog( state.translate(e.message, { size: bytes(maxSize), count: LIMITS.MAX_FILES_PER_ARCHIVE @@ -110,11 +111,12 @@ export default function(state, emitter) { emitter.on('upload', async ({ type, dlimit, password }) => { if (!state.archive) return; if (state.storage.files.length >= LIMITS.MAX_ARCHIVES_PER_USER) { - return alert( + state.modal = okDialog( state.translate('tooManyArchives', { count: LIMITS.MAX_ARCHIVES_PER_USER }) ); + return render(); } const size = state.archive.size; if (!state.timeLimit) state.timeLimit = DEFAULTS.EXPIRE_SECONDS; diff --git a/app/main.css b/app/main.css index afc2040b..71d87247 100644 --- a/app/main.css +++ b/app/main.css @@ -1,23 +1,25 @@ @import './base.css'; -@import './templates/activeBackground/activeBackground.css'; -@import './templates/header/header.css'; -@import './templates/downloadButton/downloadButton.css'; -@import './templates/passwordInput/passwordInput.css'; -@import './templates/downloadPassword/downloadPassword.css'; -@import './templates/setPasswordSection/setPasswordSection.css'; -@import './templates/footer/footer.css'; -@import './templates/fxPromo/fxPromo.css'; -@import './templates/selectbox/selectbox.css'; -@import './templates/fileList/fileList.css'; -@import './templates/file/file.css'; -@import './templates/uploadedFile/uploadedFile.css'; -@import './templates/uploadedFileList/uploadedFileList.css'; -@import './templates/popup/popup.css'; -@import './templates/title/title.css'; -@import './templates/fileIcon/fileIcon.css'; -@import './templates/signupPromo/signupPromo.css'; -@import './templates/userAccount/userAccount.css'; -@import './pages/welcome/welcome.css'; @import './pages/share/share.css'; @import './pages/signin/signin.css'; @import './pages/unsupported/unsupported.css'; +@import './pages/welcome/welcome.css'; +@import './templates/activeBackground/activeBackground.css'; +@import './templates/downloadButton/downloadButton.css'; +@import './templates/downloadPassword/downloadPassword.css'; +@import './templates/file/file.css'; +@import './templates/fileIcon/fileIcon.css'; +@import './templates/fileList/fileList.css'; +@import './templates/footer/footer.css'; +@import './templates/fxPromo/fxPromo.css'; +@import './templates/header/header.css'; +@import './templates/modal/modal.css'; +@import './templates/okDialog/okDialog.css'; +@import './templates/passwordInput/passwordInput.css'; +@import './templates/popup/popup.css'; +@import './templates/selectbox/selectbox.css'; +@import './templates/setPasswordSection/setPasswordSection.css'; +@import './templates/signupPromo/signupPromo.css'; +@import './templates/title/title.css'; +@import './templates/uploadedFile/uploadedFile.css'; +@import './templates/uploadedFileList/uploadedFileList.css'; +@import './templates/userAccount/userAccount.css'; diff --git a/app/main.js b/app/main.js index 141299cc..0e70a81e 100644 --- a/app/main.js +++ b/app/main.js @@ -35,6 +35,7 @@ import { getFileListKey } from './fxa'; state.raven = Raven; state.user = new User(userInfo, storage); window.appState = state; + window.appEmit = emitter.emit.bind(emitter); let unsupportedReason = null; if ( // Firefox < 50 diff --git a/app/routes/index.js b/app/routes/index.js index d596001f..580a9505 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -8,6 +8,7 @@ const signupPromo = require('../templates/signupPromo'); const activeBackground = require('../templates/activeBackground'); const fileList = require('../templates/fileList'); const profile = require('../templates/userAccount'); +const modal = require('../templates/modal'); nanotiming.disabled = true; const app = choo(); @@ -18,9 +19,16 @@ function banner(state, emit) { } } +function modalDialog(state, emit) { + if (state.modal) { + return modal(state, emit); + } +} + function body(template) { return function(state, emit) { const b = html` + ${modalDialog(state, emit)} ${banner(state, emit)}