git ssb

10+

Matt McKegg / patchwork



Tree: e5ad753b8414d998113f9305e0826f4cf1035fe4

Files: e5ad753b8414d998113f9305e0826f4cf1035fe4 / modules / invite / sheet.js

2336 bytesRaw
1var {h, when, Value, Proxy} = require('mutant')
2var nest = require('depnest')
3var electron = require('electron')
4
5var appRoot = require('app-root-path');
6var i18n = require(appRoot + '/lib/i18n').i18n
7
8exports.needs = nest({
9 'sheet.display': 'first',
10 'invite.async.accept': 'first'
11})
12
13exports.gives = nest('invite.sheet')
14
15exports.create = function (api) {
16 return nest('invite.sheet', function () {
17 api.sheet.display(close => {
18 var publishing = Value()
19 var publishStatus = Proxy()
20
21 var input = h('input', {
22 style: {
23 'font-size': '200%',
24 'margin-top': '20px',
25 'width': '100%'
26 },
27 placeholder: i18n.__('paste invite code here')
28 })
29 setTimeout(() => {
30 input.focus()
31 input.select()
32 }, 5)
33 return {
34 content: h('div', {
35 style: {
36 padding: '20px'
37 }
38 }, [
39 h('h2', {
40 style: {
41 'font-weight': 'normal'
42 }
43 }, [i18n.__('By default, Patchwork will only see other users that are on the same local area network as you.')]),
44 h('div', [
45 i18n.__('In order to share with users on the internet, you need to be invited to a pub server.')
46 ]),
47 input
48 ]),
49 footer: [
50 h('button -save', {
51 disabled: publishing,
52 'ev-click': () => {
53 publishing.set(true)
54 publishStatus.set(api.invite.async.accept(input.value.trim(), (err) => {
55 if (err) {
56 publishing.set(false)
57 showDialog({
58 type: 'error',
59 title: i18n.__('Error'),
60 buttons: [i18n.__('OK')],
61 message: i18n.__('An error occurred while attempting to redeem invite.'),
62 detail: err.message
63 })
64 } else {
65 close()
66 }
67 }))
68 }
69 }, [ when(publishing, publishStatus, i18n.__('Redeem Invite')) ]),
70 h('button -cancel', {
71 'ev-click': close
72 }, i18n.__('Cancel'))
73 ]
74 }
75 })
76 })
77}
78
79function showDialog (opts) {
80 electron.remote.dialog.showMessageBox(electron.remote.getCurrentWindow(), opts)
81}
82

Built with git-ssb-web