summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2017-02-24 20:35:24 -0800
committerelijah <elijah@riseup.net>2017-02-24 20:35:48 -0800
commit1a9968c1e2592be5baae4bf2c6551ad7f5228f17 (patch)
tree6b1c254626e9dc7240858e73f7d9cb2e1232512a
parent904e99c658e647a1c9acbb80a1f54c593a57bf61 (diff)
[bug] update UI to use current API
-rw-r--r--ui/app/app.js34
-rw-r--r--ui/app/components/main_panel/email_section.js39
-rw-r--r--ui/app/components/main_panel/index.js14
-rw-r--r--ui/app/models/account.js17
4 files changed, 50 insertions, 54 deletions
diff --git a/ui/app/app.js b/ui/app/app.js
index 05dadf1f..ea7f0f52 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -16,21 +16,25 @@ class Application {
}
start() {
- Provider.list(false).then(domains => {
- Account.initializeList(domains)
- Account.active().then(account => {
- if (account == null) {
- this.show('greeter')
- } else {
- Account.addPrimary(account)
- this.show('main', {initialAccount: account})
- }
- }, error => {
- this.showError(error)
- })
- }, error => {
- this.showError(error)
- })
+ Provider.list(false).then(
+ domains => {
+ Account.initializeList(domains)
+ Account.active().then(
+ accounts => {
+ if (0 == accounts.length) {
+ this.show('greeter')
+ } else {
+ accounts.forEach(account => {
+ Account.addActive(account)
+ })
+ this.show('main', {initialAccount: Account.list[0]})
+ }
+ },
+ error => {this.showError(error)}
+ )
+ },
+ error => {this.showError(error)}
+ )
}
show(panel, properties) {
diff --git a/ui/app/components/main_panel/email_section.js b/ui/app/components/main_panel/email_section.js
index c86188eb..e48b8e27 100644
--- a/ui/app/components/main_panel/email_section.js
+++ b/ui/app/components/main_panel/email_section.js
@@ -74,19 +74,15 @@ export default class EmailSection extends React.Component {
}
componentWillMount() {
- //let events = [].concat(GENERAL_NOTICES, ACCOUNT_NOTICES, STATUSES, STATUS_ERRORS)
- //for (let event of events) {
- // bitmask.events.register(event, this.logEvent)
- //}
+ let events = [].concat(GENERAL_NOTICES, ACCOUNT_NOTICES, STATUSES, STATUS_ERRORS)
+ for (let event of events) {
+ bitmask.events.register(event, this.logEvent)
+ }
bitmask.mail.status().then(status => {
- // either 'running' or 'disabled'
- let newstatus = 'error'
- if (status['mail'] == 'running') {
- newstatus = 'on'
- } else if (status['mail'] == 'disabled') {
- newstatus = 'disabled'
- }
- this.setState({status: newstatus})
+ this.setState({
+ status: status.status,
+ error: status.error
+ })
})
}
@@ -107,13 +103,13 @@ export default class EmailSection extends React.Component {
}
render () {
- //let message = null
- //if (this.state.error) {
- // // style may be: success, warning, danger, info
- // message = (
- // <Alert bsStyle="danger">{this.state.error}</Alert>
- // )
- //}
+ let message = null
+ if (this.state.error) {
+ // style may be: success, warning, danger, info
+ message = (
+ <Alert bsStyle="danger">{this.state.error}</Alert>
+ )
+ }
let button = null
let body = null
let header = <h1>Mail</h1>
@@ -124,12 +120,13 @@ export default class EmailSection extends React.Component {
header = <h1>Mail Disabled</h1>
}
if (this.state.expanded) {
- body = (
+ body = (<div>
+ {message}
<ButtonToolbar>
<IMAPButton account={this.props.account} />
<Button onClick={this.openKeys}>Addressbook</Button>
</ButtonToolbar>
- )
+ </div>)
}
return (
<SectionLayout icon="envelope" status={this.state.status}
diff --git a/ui/app/components/main_panel/index.js b/ui/app/components/main_panel/index.js
index 05a1e903..cac58cbb 100644
--- a/ui/app/components/main_panel/index.js
+++ b/ui/app/components/main_panel/index.js
@@ -76,14 +76,12 @@ export default class MainPanel extends React.Component {
}
}
- if (false) {
- sidePanel = (
- <AccountList account={this.state.account}
- accounts={this.state.accounts}
- onSelect={this.activateAccount}
- onRemove={this.removeAccount}/>
- )
- }
+ sidePanel = (
+ <AccountList account={this.state.account}
+ accounts={this.state.accounts}
+ onSelect={this.activateAccount}
+ onRemove={this.removeAccount}/>
+ )
return (
<div className="main-panel">
diff --git a/ui/app/models/account.js b/ui/app/models/account.js
index 0251da03..3656d2c7 100644
--- a/ui/app/models/account.js
+++ b/ui/app/models/account.js
@@ -109,19 +109,16 @@ export default class Account {
}
//
- // returns a promise, fullfill is passed account object
+ // returns a list of the authenticated accounts
//
static active() {
- if (!bitmask.api_token()) {
- return new Promise((resolve, reject) => {resolve(null)})
- }
- return bitmask.bonafide.user.active().then(
+ return bitmask.bonafide.user.list().then(
response => {
- if (response.user == '<none>') {
- return null
- } else {
- return new Account(response.user, {authenticated: true})
+ let list = []
+ for (let accountProps of response) {
+ list.push(new Account(accountProps.userid, accountProps))
}
+ return list
}
)
}
@@ -181,7 +178,7 @@ export default class Account {
// this is a temporary hack to support the old behavior
// util the backend has a proper concept of an account list.
//
- static addPrimary(account) {
+ static addActive(account) {
Account.list = Account.list.filter(i => {
return i.domain != account.domain
})