From 11e7cef0575143e555e88709808b1be33617447c Mon Sep 17 00:00:00 2001 From: Adomas Ven Date: Mon, 27 Jun 2016 19:40:38 +0300 Subject: [PATCH] Show hard warning dialog when unlinking or linking to a different account (#1047) And give option to delete local data when unlinking This removes the old behavior of merging accounts when syncing with a different username. --- .../content/zotero/hardConfirmationDialog.js | 78 +++++++++++++ .../content/zotero/hardConfirmationDialog.xul | 62 ++++++++++ .../zotero/preferences/preferences_sync.js | 26 ++++- chrome/content/zotero/xpcom/notifier.js | 8 +- chrome/content/zotero/xpcom/sync/syncLocal.js | 106 ++++++++---------- .../content/zotero/xpcom/sync/syncRunner.js | 6 +- .../zotero/xpcom/utilities_internal.js | 9 ++ chrome/content/zotero/xpcom/zotero.js | 65 +++++++++-- chrome/content/zotero/zoteroPane.js | 6 +- chrome/locale/en-US/zotero/zotero.properties | 19 ++-- test/tests/preferences_syncTest.js | 11 ++ test/tests/syncLocalTest.js | 79 +++++++------ 12 files changed, 353 insertions(+), 122 deletions(-) create mode 100644 chrome/content/zotero/hardConfirmationDialog.js create mode 100644 chrome/content/zotero/hardConfirmationDialog.xul diff --git a/chrome/content/zotero/hardConfirmationDialog.js b/chrome/content/zotero/hardConfirmationDialog.js new file mode 100644 index 000000000..5b0399810 --- /dev/null +++ b/chrome/content/zotero/hardConfirmationDialog.js @@ -0,0 +1,78 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2016 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +Zotero.HardConfirmationDialog = { + init: function() { + var label, content; + this.io = window.arguments[0]; + + var vbox = document.getElementById('infoContainer'); + var sep = vbox.firstChild; + for (let text of this.io.text) { + label = document.createElement('label'); + content = document.createTextNode(text); + label.appendChild(content); + vbox.insertBefore(label, sep); + } + if (this.io.checkboxLabel) { + var checkbox = document.getElementById('zotero-hardConfirmationDialog-checkbox'); + checkbox.hidden = false; + checkbox.setAttribute('label', this.io.checkboxLabel); + this.onCheckbox(); + } + if (this.io.confirmationText) { + document.getElementById('zotero-hardConfirmationDialog-textbox').hidden = false; + this.onKeyUp(); + } + + if (this.io.extra1Label) { + document.documentElement.buttons = document.documentElement.buttons + ',extra1'; + document.documentElement.getButton('extra1').label = this.io.extra1Label + } if (this.io.acceptLabel) { + document.documentElement.getButton('accept').label = this.io.acceptLabel + } + + document.documentElement.setAttribute('title', this.io.title); + }, + + onCheckbox: function(event) { + document.documentElement.getButton('accept').disabled = + !document.getElementById('zotero-hardConfirmationDialog-checkbox').checked; + }, + + onKeyUp: function(event) { + document.documentElement.getButton('accept').disabled = + document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText; + }, + + onAccept: function() { + this.io.accept = true; + }, + + onExtra1: function() { + this.io.extra1 = true; + document.documentElement.cancelDialog(); + } +}; diff --git a/chrome/content/zotero/hardConfirmationDialog.xul b/chrome/content/zotero/hardConfirmationDialog.xul new file mode 100644 index 000000000..c3c6d5f6a --- /dev/null +++ b/chrome/content/zotero/hardConfirmationDialog.xul @@ -0,0 +1,62 @@ + + + + + + + + + %zoteroDTD; ]> + + + +