Skip to content

Commit e124946

Browse files
authored
Combine Export / Import & Storage & Backup #599 (#605)
1 parent 9012e73 commit e124946

File tree

6 files changed

+116
-151
lines changed

6 files changed

+116
-151
lines changed

_locales/en/messages.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@
8787
"message": "About",
8888
"description": "About."
8989
},
90-
"export_import": {
91-
"message": "Export / Import",
92-
"description": "Export and Import."
93-
},
9490
"settings": {
9591
"message": "Settings",
9692
"description": "Settings."
@@ -313,20 +309,12 @@
313309
"message": "High Contrast",
314310
"description": "High Contrast theme"
315311
},
316-
"storage_menu": {
317-
"message": "Storage & Backup",
318-
"description": "Storage and sync menu title"
319-
},
320-
"storage_location_info": {
321-
"message": "Choose where your data is stored. Using 'local' stores your data on your PC. Using 'sync' lets your browser sync your data to the cloud if you are signed into a sync account.",
322-
"description": "Message explaning the diffrences between sync and local storage spaces."
323-
},
324312
"storage_sync_info": {
325313
"message": "Automatically backup your data to 3rd party storage services.",
326314
"description": "3rd party backup info"
327315
},
328-
"storage_location": {
329-
"message": "Storage Location",
316+
"browser_sync": {
317+
"message": "Browser Sync",
330318
"description": "Storage location"
331319
},
332320
"sign_in": {
@@ -388,5 +376,11 @@
388376
},
389377
"smart_filter": {
390378
"message": "Smart Filter"
379+
},
380+
"backup": {
381+
"message": "Backup"
382+
},
383+
"backup_file_info": {
384+
"message": "Backup your data to a file."
391385
}
392386
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<template>
22
<div>
3+
<!-- File Backup -->
34
<div v-show="!exportDisabled">
45
<div class="text warning" v-if="!encryption.getEncryptionStatus()">
56
{{ i18n.export_info }}
67
</div>
8+
<div class="text">
9+
{{ i18n.backup_file_info }}
10+
</div>
711
<div class="text warning" v-if="unsupportedAccounts">
812
{{ i18n.otp_unsupported_warn }}
913
</div>
@@ -27,6 +31,17 @@
2731
>
2832
</div>
2933
<a-button-link href="import.html">{{ i18n.import_backup }}</a-button-link>
34+
<br />
35+
<!-- 3rd Party Backup Services -->
36+
<div v-show="!backupDisabled">
37+
<div class="text">
38+
{{ i18n.storage_sync_info }}
39+
</div>
40+
<p></p>
41+
<a-button @click="showInfo('DrivePage')"> Google Drive </a-button>
42+
<a-button @click="showInfo('OneDrivePage')"> OneDrive </a-button>
43+
<a-button @click="showInfo('DropboxPage')"> Dropbox </a-button>
44+
</div>
3045
</div>
3146
</template>
3247
<script lang="ts">
@@ -59,6 +74,59 @@ export default Vue.extend({
5974
currentlyEncrypted: function () {
6075
return this.$store.getters["accounts/currentlyEncrypted"];
6176
},
77+
backupDisabled: function () {
78+
return this.$store.getters["menu/storageArea"];
79+
},
80+
},
81+
methods: {
82+
showInfo(tab: string) {
83+
if (tab === "DropboxPage") {
84+
chrome.permissions.request(
85+
{ origins: ["https://*.dropboxapi.com/*"] },
86+
async (granted) => {
87+
if (granted) {
88+
this.$store.commit("style/showInfo");
89+
this.$store.commit("currentView/changeView", tab);
90+
}
91+
}
92+
);
93+
return;
94+
} else if (tab === "DrivePage") {
95+
chrome.permissions.request(
96+
{
97+
origins: [
98+
"https://www.googleapis.com/*",
99+
"https://accounts.google.com/o/oauth2/revoke",
100+
],
101+
},
102+
async (granted) => {
103+
if (granted) {
104+
this.$store.commit("style/showInfo");
105+
this.$store.commit("currentView/changeView", tab);
106+
}
107+
return;
108+
}
109+
);
110+
return;
111+
} else if (tab === "OneDrivePage") {
112+
chrome.permissions.request(
113+
{
114+
origins: [
115+
"https://graph.microsoft.com/me/*",
116+
"https://login.microsoftonline.com/common/oauth2/v2.0/token",
117+
],
118+
},
119+
async (granted) => {
120+
if (granted) {
121+
this.$store.commit("style/showInfo");
122+
this.$store.commit("currentView/changeView", tab);
123+
}
124+
return;
125+
}
126+
);
127+
return;
128+
}
129+
},
62130
},
63131
});
64132

src/components/Popup/MenuPage.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@
1515
</a>
1616
</div>
1717
<div class="menuList">
18-
<p
19-
v-bind:title="i18n.export_import"
20-
v-on:click="showInfo('ExportPage')"
21-
>
22-
<span><IconExchange /></span>{{ i18n.export_import }}
23-
</p>
24-
<p
25-
v-bind:title="i18n.storage_menu"
26-
v-on:click="showInfo('StorageSyncConfPage')"
27-
>
28-
<span><IconDatabase /></span>{{ i18n.storage_menu }}
18+
<p v-bind:title="i18n.backup" v-on:click="showInfo('BackupPage')">
19+
<span><IconExchange /></span>{{ i18n.backup }}
2920
</p>
3021
<p
3122
v-bind:title="i18n.security"

src/components/Popup/PageHandler.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ import AddAccountPage from "./AddAccountPage.vue";
1919
import AddMethodPage from "./AddMethodPage.vue";
2020
import SetPasswordPage from "./SetPasswordPage.vue";
2121
import EnterPasswordPage from "./EnterPasswordPage.vue";
22-
import ExportPage from "./ExportPage.vue";
22+
import BackupPage from "./BackupPage.vue";
2323
import DropboxPage from "./DropboxPage.vue";
2424
import DrivePage from "./DrivePage.vue";
2525
import OneDrivePage from "./OneDrivePage.vue";
26-
import StorageSyncConfPage from "./StorageSyncConfPage.vue";
2726
import PreferencesPage from "./PreferencesPage.vue";
2827
import LoadingPage from "./LoadingPage.vue";
2928
@@ -44,12 +43,11 @@ export default Vue.extend({
4443
AddMethodPage,
4544
SetPasswordPage,
4645
EnterPasswordPage,
47-
ExportPage,
46+
BackupPage,
4847
DropboxPage,
4948
DrivePage,
5049
OneDrivePage,
5150
PreferencesPage,
52-
StorageSyncConfPage,
5351
LoadingPage,
5452
},
5553
});

src/components/Popup/PreferencesPage.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
</a-select-input>
2929
<a-toggle-input :label="i18n.use_autofill" v-model="useAutofill" />
3030
<a-toggle-input :label="i18n.smart_filter" v-model="smartFilter" />
31+
<a-toggle-input
32+
:label="i18n.browser_sync"
33+
v-model="browserSync"
34+
:disabled="storageArea"
35+
@change="migrateStorage()"
36+
/>
3137
<div class="control-group" v-show="encryption.getEncryptionStatus()">
3238
<label class="combo-label">{{ i18n.autolock }}</label>
3339
<input
@@ -101,6 +107,23 @@ export default Vue.extend({
101107
chrome.runtime.sendMessage({ action: "resetAutolock" });
102108
},
103109
},
110+
storageArea() {
111+
return this.$store.state.menu.storageArea;
112+
},
113+
browserSync: {
114+
get(): boolean {
115+
return this.newStorageLocation === "sync";
116+
},
117+
set(value) {
118+
this.newStorageLocation = value ? "sync" : "local";
119+
},
120+
},
121+
},
122+
data() {
123+
return {
124+
newStorageLocation:
125+
this.$store.state.menu.storageArea || localStorage.storageLocation,
126+
};
104127
},
105128
methods: {
106129
popOut() {
@@ -117,6 +140,19 @@ export default Vue.extend({
117140
width: window.innerWidth,
118141
});
119142
},
143+
migrateStorage() {
144+
this.$store.commit("currentView/changeView", "LoadingPage");
145+
this.$store
146+
.dispatch("accounts/migrateStorage", this.newStorageLocation)
147+
.then((m) => {
148+
this.$store.commit("notification/alert", this.i18n[m]);
149+
this.$store.commit("currentView/changeView", "PreferencesPage");
150+
}),
151+
(r: string) => {
152+
this.$store.commit("notification/alert", this.i18n.updateFailure + r);
153+
this.$store.commit("currentView/changeView", "PreferencesPage");
154+
};
155+
},
120156
},
121157
});
122158
</script>

src/components/Popup/StorageSyncConfPage.vue

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)