git ssb

2+

mixmix / ticktack



Tree: f34a56f91e29caba11aae4f1efe7ce7443c9f032

Files: f34a56f91e29caba11aae4f1efe7ce7443c9f032 / backup / html / backup.js

2519 bytesRaw
1const nest = require('depnest')
2const { h, computed, Value, resolve } = require('mutant')
3const electron = require('electron')
4const { dialog } = require('electron').remote;
5const path = require('path')
6const fs = require('fs')
7
8exports.gives = nest({
9 'backup.html': ['exportIdentityButton', 'importIdentityButton']
10})
11
12exports.needs = nest({
13 'app.html.lightbox': 'first',
14 'keys.sync.id': 'first',
15 'translations.sync.strings': 'first',
16 'backup.async.exportIdentity': 'first'
17})
18
19exports.create = (api) => {
20 return nest('backup.html', { exportIdentityButton, importIdentityButton })
21
22 function exportIdentityButton() {
23 const strings = api.translations.sync.strings()
24
25 let isOpen = Value(false)
26 let encryptionKeyRaw = Value('')
27
28 let encryptionKeyInput = h('textarea#encryptionKey', {
29 style: {
30 width: '90%'
31 },
32 placeholder: strings.backup.export.passwordPlaceholder,
33 value: encryptionKeyRaw,
34 'ev-input': () => encryptionKeyRaw.set(encryptionKeyInput.value),
35 })
36
37 let exportDialog = h('div.dialog', {
38 style: {
39 'text-align': 'left'
40 }
41 },
42 [
43 h('div.message', [
44 h('h1', strings.backup.export.header),
45 h('p', strings.backup.export.message[0]),
46 h('p', strings.backup.export.message[1])
47 ]),
48 h('div.form', [
49 encryptionKeyInput
50 ]),
51 h('div.actions', [
52 h('Button', { 'ev-click': () => isOpen.set(false) }, strings.backup.export.cancelAction),
53 h('Button -primary', {
54 'ev-click': () => {
55 dialog.showSaveDialog(
56 {
57 title: strings.backup.export.dialog.title,
58 butttonLabel: strings.backup.export.dialog.label,
59 defaultPath: 'ticktack-identity.backup',
60 },
61 (filename) => api.backup.async.exportIdentity(
62 resolve(encryptionKeyRaw), filename, () => isOpen.set(false)
63 )
64 )
65 }
66 }, strings.backup.export.exportAction)
67 ])
68 ])
69
70 let lb = api.app.html.lightbox(exportDialog, isOpen)
71
72 return h('div.backupKeys', [
73 h('Button -backup', { 'ev-click': () => isOpen.set(true) }, strings.backup.export.exportAction),
74 lb
75 ])
76 }
77
78 function importIdentityButton() {
79 const strings = api.translations.sync.strings()
80
81 return h('div.backupKeys', [
82 h('Button -backup', strings.backup.import.importAction)
83 ])
84 }
85}
86

Built with git-ssb-web