mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
Bug 1092953: show a modal confirm dialog when a user attempts to delete a room. r=paolo
This commit is contained in:
parent
dee3c94d20
commit
c20ee339fb
@ -365,21 +365,31 @@ function injectLoopAPI(targetWindow) {
|
||||
/**
|
||||
* Displays a confirmation dialog using the specified strings.
|
||||
*
|
||||
* Callback parameters:
|
||||
* - err null on success, non-null on unexpected failure to show the prompt.
|
||||
* - {Boolean} True if the user chose the OK button.
|
||||
* @param {Object} options Confirm dialog options
|
||||
* @param {Function} callback Function that will be invoked once the operation
|
||||
* finished. The first argument passed will be an
|
||||
* `Error` object or `null`. The second argument
|
||||
* will be the result of the operation, TRUE if
|
||||
* the user chose the OK button.
|
||||
*/
|
||||
confirm: {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: function(bodyMessage, okButtonMessage, cancelButtonMessage, callback) {
|
||||
try {
|
||||
let buttonFlags =
|
||||
value: function(options, callback) {
|
||||
let buttonFlags;
|
||||
if (options.okButton && options.cancelButton) {
|
||||
buttonFlags =
|
||||
(Ci.nsIPrompt.BUTTON_POS_0 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING) +
|
||||
(Ci.nsIPrompt.BUTTON_POS_1 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING);
|
||||
} else if (!options.okButton && !options.cancelButton) {
|
||||
buttonFlags = Services.prompt.STD_YES_NO_BUTTONS;
|
||||
} else {
|
||||
callback(cloneValueInto(new Error("confirm: missing button options"), targetWindow));
|
||||
}
|
||||
|
||||
try {
|
||||
let chosenButton = Services.prompt.confirmEx(null, "",
|
||||
bodyMessage, buttonFlags, okButtonMessage, cancelButtonMessage,
|
||||
options.message, buttonFlags, options.okButton, options.cancelButton,
|
||||
null, null, {});
|
||||
|
||||
callback(null, chosenButton == 0);
|
||||
|
@ -403,25 +403,25 @@ loop.contacts = (function(_, mozL10n) {
|
||||
this.props.startForm("contacts_edit", contact);
|
||||
break;
|
||||
case "remove":
|
||||
navigator.mozLoop.confirm(
|
||||
mozL10n.get("confirm_delete_contact_alert"),
|
||||
mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
mozL10n.get("confirm_delete_contact_cancel_button"),
|
||||
(err, result) => {
|
||||
navigator.mozLoop.confirm({
|
||||
message: mozL10n.get("confirm_delete_contact_alert"),
|
||||
okButton: mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
cancelButton: mozL10n.get("confirm_delete_contact_cancel_button")
|
||||
}, (err, result) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "block":
|
||||
case "unblock":
|
||||
|
@ -403,25 +403,25 @@ loop.contacts = (function(_, mozL10n) {
|
||||
this.props.startForm("contacts_edit", contact);
|
||||
break;
|
||||
case "remove":
|
||||
navigator.mozLoop.confirm(
|
||||
mozL10n.get("confirm_delete_contact_alert"),
|
||||
mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
mozL10n.get("confirm_delete_contact_cancel_button"),
|
||||
(err, result) => {
|
||||
navigator.mozLoop.confirm({
|
||||
message: mozL10n.get("confirm_delete_contact_alert"),
|
||||
okButton: mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
cancelButton: mozL10n.get("confirm_delete_contact_cancel_button")
|
||||
}, (err, result) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "block":
|
||||
case "unblock":
|
||||
|
@ -617,10 +617,23 @@ loop.panel = (function(_, mozL10n) {
|
||||
handleDeleteButtonClick: function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
// XXX We should prompt end user for confirmation; see bug 1092953.
|
||||
this.props.dispatcher.dispatch(new sharedActions.DeleteRoom({
|
||||
roomToken: this.props.room.roomToken
|
||||
}));
|
||||
navigator.mozLoop.confirm({
|
||||
message: mozL10n.get("rooms_list_deleteConfirmation_label"),
|
||||
okButton: null,
|
||||
cancelButton: null
|
||||
}, function(err, result) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.dispatcher.dispatch(new sharedActions.DeleteRoom({
|
||||
roomToken: this.props.room.roomToken
|
||||
}));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
renameRoom: function(newRoomName) {
|
||||
|
@ -617,10 +617,23 @@ loop.panel = (function(_, mozL10n) {
|
||||
handleDeleteButtonClick: function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
// XXX We should prompt end user for confirmation; see bug 1092953.
|
||||
this.props.dispatcher.dispatch(new sharedActions.DeleteRoom({
|
||||
roomToken: this.props.room.roomToken
|
||||
}));
|
||||
navigator.mozLoop.confirm({
|
||||
message: mozL10n.get("rooms_list_deleteConfirmation_label"),
|
||||
okButton: null,
|
||||
cancelButton: null
|
||||
}, function(err, result) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.dispatcher.dispatch(new sharedActions.DeleteRoom({
|
||||
roomToken: this.props.room.roomToken
|
||||
}));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
renameRoom: function(newRoomName) {
|
||||
|
Loading…
Reference in New Issue
Block a user