Skip to content
Permalink
Browse files

Issue #94 - Converted panel to the Vue.js framework

  • Loading branch information...
palant committed May 5, 2019
1 parent 37fae99 commit ad4ea5554d54c3db708b2e577636d39bfad7d1e0
Showing with 2,553 additions and 2,343 deletions.
  1. +7 −3 .eslintrc.json
  2. +9 −9 data/allpasswords/main.js
  3. +22 −0 data/i18n.js
  4. +113 −0 data/panel/App.vue
  5. +0 −82 data/panel/changeMaster.js
  6. +43 −0 data/panel/components/Confirm.vue
  7. +59 −0 data/panel/components/ExternalLink.vue
  8. +197 −0 data/panel/components/GeneratedPassword.vue
  9. +40 −0 data/panel/components/ManualAuth.vue
  10. +82 −0 data/panel/components/ModalOverlay.vue
  11. +56 −0 data/panel/components/NotesEditor.vue
  12. +222 −0 data/panel/components/PasswordEntry.vue
  13. +70 −0 data/panel/components/PasswordMenu.vue
  14. +56 −0 data/panel/components/PasswordMessage.vue
  15. +43 −0 data/panel/components/PasswordScore.vue
  16. +68 −0 data/panel/components/QRCode.vue
  17. +121 −0 data/panel/components/RecoveryCode.vue
  18. +122 −0 data/panel/components/StoredPassword.vue
  19. +52 −0 data/panel/components/ValidatedForm.vue
  20. +52 −0 data/panel/components/ValidatedInput.vue
  21. +0 −47 data/panel/confirm.js
  22. +0 −39 data/panel/enterMaster.js
  23. +0 −73 data/panel/events.js
  24. +0 −137 data/panel/formValidation.js
  25. +0 −97 data/panel/generatePassword.js
  26. +44 −35 data/panel/main.js
  27. +0 −47 data/panel/migration.js
  28. +0 −51 data/panel/notes.js
  29. +104 −0 data/panel/pages/changeMaster.vue
  30. +66 −0 data/panel/pages/enterMaster.vue
  31. +88 −0 data/panel/pages/migration.vue
  32. +165 −0 data/panel/pages/passwordList.vue
  33. +156 −0 data/panel/pages/siteSelection.vue
  34. +194 −0 data/panel/pages/sync.vue
  35. +1 −312 data/panel/panel.html
  36. +105 −93 data/panel/panel.scss
  37. +0 −430 data/panel/passwordList.js
  38. +0 −67 data/panel/qrcode.js
  39. +0 −133 data/panel/recoveryCode.js
  40. +44 −0 data/panel/router.js
  41. +0 −160 data/panel/siteSelection.js
  42. +0 −43 data/panel/state.js
  43. +0 −70 data/panel/storedPassword.js
  44. +0 −42 data/panel/syncAuthorize.js
  45. +0 −67 data/panel/syncSetup.js
  46. +0 −124 data/panel/syncState.js
  47. +0 −114 data/panel/utils.js
  48. +97 −20 gulpfile.js
  49. +5 −4 lib/passwordRetrieval.js
  50. +11 −11 lib/passwords.js
  51. +2 −2 lib/recoveryCodes.js
  52. +3 −2 locale/en-US.properties
  53. +6 −1 package.json
  54. +27 −27 test/passwords.js
  55. +1 −1 test/recoveryCodes.js
@@ -1,8 +1,9 @@
{
"root": true,
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:vue/recommended"],
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"node": true,
@@ -70,6 +71,9 @@
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yield-star-spacing": "error"
"yield-star-spacing": "error",
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline": "off",
"vue/max-attributes-per-line": "off"
}
}
@@ -14,9 +14,9 @@ let modal = require("./modal");
let {passwords, passwordRetrieval, recoveryCodes} = require("../proxy");
let {port} = require("../messaging");

function copyToClipboard(site, password, passwordInfo)
function copyToClipboard(passwordData, passwordInfo)
{
passwords.getPassword(site, password.name, password.revision).then(password =>
passwords.getPassword(passwordData).then(password =>
{
let doCopy = () =>
{
@@ -49,12 +49,12 @@ function copyToClipboard(site, password, passwordInfo)
}).catch(showError);
}

function removePassword(site, password, passwordInfo)
function removePassword(passwordData, passwordInfo)
{
let message = i18n.getMessage("remove_password_confirmation").replace(/\{1\}/g, password.name).replace(/\{2\}/g, site);
let message = i18n.getMessage("remove_password_confirmation").replace(/\{1\}/g, passwordData.name).replace(/\{2\}/g, passwordData.site);
if (confirm(message))
{
passwords.removePassword(site, password.name, password.revision).then(() =>
passwords.removePassword(passwordData).then(() =>
{
let siteInfo = passwordInfo.parentNode;
siteInfo.removeChild(passwordInfo);
@@ -187,7 +187,7 @@ function showPasswords(event)
{
let passwordInfo = elements[i];
let [site, passwordData] = passwordInfo._data;
actions.push(passwords.getPassword(site, passwordData.name, passwordData.revision)
actions.push(passwords.getPassword(passwordData)
.then(value =>
{
let element = passwordInfo.querySelector(".password-value");
@@ -313,8 +313,8 @@ window.addEventListener("DOMContentLoaded", function()
revisionNode.hidden = !passwordData.revision;
revisionNode.textContent = passwordData.revision;

setCommandHandler(passwordInfo.querySelector(".to-clipboard-link"), copyToClipboard.bind(null, site, passwordData, passwordInfo));
setCommandHandler(passwordInfo.querySelector(".password-remove-link"), removePassword.bind(null, site, passwordData, passwordInfo));
setCommandHandler(passwordInfo.querySelector(".to-clipboard-link"), copyToClipboard.bind(null, passwordData, passwordInfo));
setCommandHandler(passwordInfo.querySelector(".password-remove-link"), removePassword.bind(null, passwordData, passwordInfo));

if (passwordData.type == "generated2" || passwordData.type == "generated")
{
@@ -338,7 +338,7 @@ window.addEventListener("DOMContentLoaded", function()
else
{
passwordInfo.querySelector(".password-info.generated").hidden = true;
recoveryCodeOperations.push(recoveryCodes.getCode(site, passwordData.name, passwordData.revision).then(code =>
recoveryCodeOperations.push(recoveryCodes.getCode(passwordData).then(code =>
{
passwordInfo.querySelector(".password-recovery").textContent = code;
}));
@@ -0,0 +1,22 @@
/*
* This Source Code is subject to the terms of the Mozilla Public License
* version 2.0 (the "License"). You can obtain a copy of the License at
* http://mozilla.org/MPL/2.0/.
*/

"use strict";

const browser = require("./browserAPI");

export default {
install: function(Vue)
{
Vue.prototype.$t = function(id, ...params)
{
let message = browser.i18n.getMessage(id);
for (let i = 0; i < params.length; i++)
message = message.replace(new RegExp(`\\{${i + 1}\\}`, "g"), params[i]);
return message;
};
}
};
@@ -0,0 +1,113 @@
<!--
- This Source Code is subject to the terms of the Mozilla Public License
- version 2.0 (the "License"). You can obtain a copy of the License at
- http://mozilla.org/MPL/2.0/.
-->

<template>
<div id="app">
<confirm ref="confirm" />

<div
v-if="unknownError"
id="unknown-error"
class="warning"
>
<span>{{ $t("unknown_error") }}</span>
<a
v-if="!unknownErrorDetails"
href="#"
@click.prevent="unknownErrorDetails = true"
>
{{ $t("unknown_error_more") }}
</a>
<div
v-else
id="unknown-error-details"
>{{ unknownError }}</div>
</div>

<router-view />
</div>
</template>

<script>
"use strict";
import {port} from "../messaging";
import router from "./router";
import Confirm from "./components/Confirm.vue";
const stateToRoute = {
"unset": ["/change-master"],
"set": ["/enter-master", "/change-master"],
"migrating": ["/migration"],
"known": ["/password-list", "/generate-password", "/stored-password", "/recovery-code", "/qrcode", "/sync-setup", "/sync-state", "/confirm"]
};
let data = {
site: null,
origSite: null,
pwdList: null,
masterPasswordState: null,
sync: null,
unknownError: null,
unknownErrorDetails: false
};
export let app = null;
export function confirm(message)
{
return new Promise((resolve, reject) =>
{
let confirm = app.$refs.confirm;
confirm.message = message;
confirm.callback = resolve;
});
}
export function showUnknownError(error)
{
app.unknownError = error;
}
port.on("init", state =>
{
let target = app || data;
for (let key of ["site", "origSite", "pwdList", "masterPasswordState", "sync"])
if (key in state)
target[key] = state[key];
});
export default {
name: "App",
components: {
confirm: Confirm
},
data: () => data,
computed: {
siteDisplayName()
{
return require("../common").getSiteDisplayName(this.site);
}
},
watch: {
masterPasswordState: function()
{
let routes = stateToRoute[this.masterPasswordState];
if (routes.indexOf(router.currentRoute.path) < 0)
{
let route = routes[0];
if (route == "/password-list" && !this.site)
route = "/site-selection";
router.push(route);
}
}
},
created: function()
{
app = this;
}
};
</script>

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,43 @@
<!--
- This Source Code is subject to the terms of the Mozilla Public License
- version 2.0 (the "License"). You can obtain a copy of the License at
- http://mozilla.org/MPL/2.0/.
-->

<template>
<modal-overlay v-if="message" @cancel="reject">
<div id="confirm-message">{{ message }}</div>
<div class="button-container">
<button v-focus @click="accept">{{ $t("yes") }}</button>
<button @click="reject">{{ $t("no") }}</button>
</div>
</modal-overlay>
</template>

<script>
"use strict";
export default {
name: "Confirm",
data()
{
return {
message: null,
callback: null
};
},
methods:
{
accept()
{
this.callback(true);
this.message = this.callback = null;
},
reject()
{
this.callback(false);
this.message = this.callback = null;
}
}
};
</script>
Oops, something went wrong.

0 comments on commit ad4ea55

Please sign in to comment.
You can’t perform that action at this time.