Clarify warnings about data removal when switching accounts

And improve styling of hardConfirmationDialog.xul

Closes #1359
This commit is contained in:
Dan Stillman 2020-05-23 03:17:34 -04:00
parent 31f26fefe7
commit c65322d0a4
6 changed files with 68 additions and 23 deletions

View file

@ -25,16 +25,24 @@
Zotero.HardConfirmationDialog = {
init: function() {
var label, content;
this.io = window.arguments[0];
Zotero.setFontSize(document.getElementById('zotero-hardConfirmationDialog'));
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);
document.getElementById('infoBody').textContent = this.io.text;
if (this.io.title) {
document.documentElement.setAttribute('title', this.io.title);
if (Zotero.isMac) {
let elem = document.getElementById('infoTitle');
elem.textContent = this.io.title;
elem.style.marginBottom = '12px';
elem.hidden = false;
}
}
if (this.io.checkboxLabel) {
var checkbox = document.getElementById('zotero-hardConfirmationDialog-checkbox');
@ -47,14 +55,17 @@ Zotero.HardConfirmationDialog = {
this.onKeyUp();
}
if (this.io.acceptLabel) {
document.documentElement.getButton('accept').label = this.io.acceptLabel
}
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);
if (this.io.extra2Label) {
document.documentElement.buttons = document.documentElement.buttons + ',extra2';
document.documentElement.getButton('extra2').label = this.io.extra2Label
}
},
onCheckbox: function(event) {
@ -74,5 +85,10 @@ Zotero.HardConfirmationDialog = {
onExtra1: function() {
this.io.extra1 = true;
document.documentElement.cancelDialog();
},
onExtra2: function() {
this.io.extra2 = true;
document.documentElement.cancelDialog();
}
};

View file

@ -28,6 +28,7 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/commonDialog.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/commonDialog.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/hardConfirmationDialog.css" type="text/css"?>
<!DOCTYPE overlay [ <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; ]>
@ -36,7 +37,8 @@
id="zotero-hardConfirmationDialog"
onload="Zotero.HardConfirmationDialog.init(); sizeToContent();"
ondialogaccept="Zotero.HardConfirmationDialog.onAccept();"
ondialogextra1="Zotero.HardConfirmationDialog.onExtra1();">
ondialogextra1="Zotero.HardConfirmationDialog.onExtra1();"
ondialogextra2="Zotero.HardConfirmationDialog.onExtra2();">
<script src="chrome://zotero/content/include.js"/>
<script src="hardConfirmationDialog.js"/>
@ -50,6 +52,9 @@
<row>
<hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox>
<vbox id="infoContainer">
<description id="infoTitle" hidden="true"/>
<description id="infoBody"/>
<separator class="thin"/>
<checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/>

View file

@ -126,13 +126,21 @@ Zotero.Sync.Data.Local = {
+ `last username '${lastUsername}', current username '${username}'`, 2);
var io = {
title: Zotero.getString('general.warning'),
text: [Zotero.getString('account.lastSyncWithDifferentAccount', [ZOTERO_CONFIG.CLIENT_NAME, lastUsername, username])],
checkboxLabel: Zotero.getString('account.confirmDelete'),
acceptLabel: Zotero.getString('account.confirmDelete.button')
text: Zotero.getString(
'account.lastSyncWithDifferentAccount',
[Zotero.appName, lastUsername, username]
) + '\n\n'
+ Zotero.getString(
'account.lastSyncWithDifferentAccount.beforeContinuing',
[lastUsername, Zotero.appName]
),
checkboxLabel: Zotero.getString('account.confirmDelete', lastUsername),
acceptLabel: Zotero.getString('account.confirmDelete.button'),
extra2Label: Zotero.getString('general.moreInformation')
};
win.openDialog("chrome://zotero/content/hardConfirmationDialog.xul", "",
"chrome, dialog, modal, centerscreen", io);
"chrome,dialog,modal,centerscreen", io);
if (io.accept) {
var resetDataDirFile = OS.Path.join(Zotero.DataDirectory.dir, 'reset-data-directory');
yield Zotero.File.putContentsAsync(resetDataDirFile, '');
@ -150,6 +158,9 @@ Zotero.Sync.Data.Local = {
return true;
}
else if (io.extra2) {
Zotero.launchURL("https://www.zotero.org/support/kb/switching_accounts");
}
return false;
}

View file

@ -984,8 +984,9 @@ account.unlinkWarning.removeData = Remove my %S data from this computer
account.unlinkWarning.button = Unlink Account
account.warning.emptyLibrary = You are about to sync the %1$S account to an empty %2$S database. This could happen if you removed your previous database or if the location of your %2$S data directory changed.
account.warning.existingDataElsewhere = If your %S data exists elsewhere on this computer, you should move it to the current data directory or change the data directory location to point to your existing data.
account.lastSyncWithDifferentAccount = This %1$S database was last synced with a different account (%2$S) from the current one (%3$S). If you continue, data associated with the %2$S account will be removed from this computer.
account.confirmDelete = Remove existing data
account.lastSyncWithDifferentAccount = This %1$S database was last synced with a different account (“%2$S”) from the one you are attempting to sync with (“%3$S”). If you continue, all %1$S libraries associated with the “%2$S” account will be removed from this computer.
account.lastSyncWithDifferentAccount.beforeContinuing = Before continuing, make sure all data and files you wish to keep have been synced with the “%S” account or you have a backup of your %S data directory.
account.confirmDelete = Remove all data for “%S” from this computer
account.confirmDelete.button = Switch Accounts
sync.conflict.autoChange.alert = One or more locally deleted Zotero %S have been modified remotely since the last sync.

View file

@ -0,0 +1,11 @@
#zotero-hardConfirmationDialog {
max-width: 500px;
}
#zotero-hardConfirmationDialog-checkbox {
font: menu;
}
#infoContainer {
margin-bottom: 6px;
}

View file

@ -45,11 +45,12 @@ describe("Zotero.Sync.Data.Local", function() {
var handled = false;
waitForDialog(function (dialog) {
var text = dialog.document.documentElement.textContent;
var matches = text.match(/[^]*/g);
assert.equal(matches.length, 3);
assert.equal(matches[0], "A");
assert.equal(matches[1], "B");
assert.equal(matches[2], "A");
var matches = text.match(/“[^”]*”/g);
assert.equal(matches.length, 4);
assert.equal(matches[0], "“A”");
assert.equal(matches[1], "“B”");
assert.equal(matches[2], "“A”");
assert.equal(matches[3], "“A”");
dialog.document.getElementById('zotero-hardConfirmationDialog-checkbox').checked = true;
dialog.document.getElementById('zotero-hardConfirmationDialog-checkbox')