Bug 1069816: Enable import button in the contacts list. r=abr

This commit is contained in:
Mike de Boer 2014-10-02 12:37:43 +02:00
parent 0b4d324d7e
commit 392056106c
2 changed files with 34 additions and 6 deletions

View File

@ -209,7 +209,8 @@ loop.contacts = (function(_, mozL10n) {
const ContactsList = React.createClass({displayName: 'ContactsList',
getInitialState: function() {
return {
contacts: {}
contacts: {},
importBusy: false
};
},
@ -272,6 +273,16 @@ loop.contacts = (function(_, mozL10n) {
},
handleImportButtonClick: function() {
this.setState({ importBusy: true });
navigator.mozLoop.startImport({
service: "google"
}, (err, stats) => {
this.setState({ importBusy: false });
// TODO: bug 1076764 - proper error and success reporting.
if (err) {
throw err;
}
});
},
handleAddContactButtonClick: function() {
@ -319,12 +330,15 @@ loop.contacts = (function(_, mozL10n) {
return contact.blocked ? "blocked" : "available";
});
// TODO: bug 1076767 - add a spinner whilst importing contacts.
return (
React.DOM.div(null,
React.DOM.div({className: "content-area"},
ButtonGroup(null,
Button({caption: mozL10n.get("import_contacts_button"),
disabled: true,
Button({caption: this.state.importBusy
? mozL10n.get("importing_contacts_progress_button")
: mozL10n.get("import_contacts_button"),
disabled: this.state.importBusy,
onClick: this.handleImportButtonClick}),
Button({caption: mozL10n.get("new_contact_button"),
onClick: this.handleAddContactButtonClick})

View File

@ -209,7 +209,8 @@ loop.contacts = (function(_, mozL10n) {
const ContactsList = React.createClass({
getInitialState: function() {
return {
contacts: {}
contacts: {},
importBusy: false
};
},
@ -272,6 +273,16 @@ loop.contacts = (function(_, mozL10n) {
},
handleImportButtonClick: function() {
this.setState({ importBusy: true });
navigator.mozLoop.startImport({
service: "google"
}, (err, stats) => {
this.setState({ importBusy: false });
// TODO: bug 1076764 - proper error and success reporting.
if (err) {
throw err;
}
});
},
handleAddContactButtonClick: function() {
@ -319,12 +330,15 @@ loop.contacts = (function(_, mozL10n) {
return contact.blocked ? "blocked" : "available";
});
// TODO: bug 1076767 - add a spinner whilst importing contacts.
return (
<div>
<div className="content-area">
<ButtonGroup>
<Button caption={mozL10n.get("import_contacts_button")}
disabled
<Button caption={this.state.importBusy
? mozL10n.get("importing_contacts_progress_button")
: mozL10n.get("import_contacts_button")}
disabled={this.state.importBusy}
onClick={this.handleImportButtonClick} />
<Button caption={mozL10n.get("new_contact_button")}
onClick={this.handleAddContactButtonClick} />