Use Z.Prompt.confirm() for delayed-button prompts to fix CI failures

After f9faa0415f, Zotero.Prompt.confirm() ignores the delayed-button
flag when running in CI.
This commit is contained in:
Dan Stillman 2024-08-28 02:22:39 -04:00
parent 92165cb9ed
commit a2bac6b299
6 changed files with 50 additions and 89 deletions

View file

@ -513,19 +513,14 @@ Zotero_Preferences.Sync = {
var sql = "SELECT COUNT(*) FROM settings "
+ "WHERE setting='storage' AND key='zfsPurge' AND value='user'";
if (!Zotero.DB.valueQueryAsync(sql)) {
let ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;
var account = Zotero.Sync.Server.username;
var index = ps.confirmEx(
null,
Zotero.getString('zotero.preferences.sync.purgeStorage.title'),
Zotero.getString('zotero.preferences.sync.purgeStorage.desc'),
buttonFlags,
Zotero.getString('zotero.preferences.sync.purgeStorage.confirmButton'),
Zotero.getString('zotero.preferences.sync.purgeStorage.cancelButton'), null, null, {}
);
var index = Zotero.Prompt.confirm({
title: Zotero.getString('zotero.preferences.sync.purgeStorage.title'),
text: Zotero.getString('zotero.preferences.sync.purgeStorage.desc'),
button0: Zotero.getString('zotero.preferences.sync.purgeStorage.confirmButton'),
button1: Zotero.getString('zotero.preferences.sync.purgeStorage.cancelButton'),
buttonDelay: true,
});
if (index == 0) {
var sql = "INSERT OR IGNORE INTO settings VALUES (?,?,?)";
@ -533,7 +528,7 @@ Zotero_Preferences.Sync = {
try {
yield Zotero.Sync.Storage.ZFS.purgeDeletedStorageFiles();
ps.alert(
Services.prompt.alert(
null,
Zotero.getString("general.success"),
"Attachment files from your personal library have been removed from the Zotero servers."
@ -541,7 +536,7 @@ Zotero_Preferences.Sync = {
}
catch (e) {
Zotero.logError(e);
ps.alert(
Services.prompt.alert(
null,
Zotero.getString("general.error"),
"An error occurred. Please try again later."

View file

@ -115,20 +115,14 @@ Zotero.Sync.Storage = new function () {
setTimeout(function () {
var group = Zotero.Groups.get(e.data.groupID);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ ps.BUTTON_DELAY_ENABLE;
var index = ps.confirmEx(
null,
Zotero.getString('general.warning'),
Zotero.getString('sync.storage.error.fileEditingAccessLost', group.name) + "\n\n"
var index = Zotero.Prompt.confirm({
title: Zotero.getString('general.warning'),
text: Zotero.getString('sync.storage.error.fileEditingAccessLost', group.name) + "\n\n"
+ Zotero.getString('sync.error.groupWillBeReset') + "\n\n"
+ Zotero.getString('sync.error.copyChangedItems'),
buttonFlags,
Zotero.getString('sync.resetGroupAndSync'),
null, null, null, {}
);
button0: Zotero.getString('sync.resetGroupAndSync'),
buttonDelay: true,
});
if (index == 0) {
// TODO: transaction

View file

@ -83,28 +83,21 @@ Zotero.Sync.Storage.Utilities = {
[library.name, ZOTERO_CONFIG.DOMAIN_NAME])
+ "\n\n"
+ Zotero.getString('sync.error.groupCopyChangedFiles')
var button1Text = Zotero.getString('sync.resetGroupFilesAndSync');
var button2Text = Zotero.getString('sync.skipGroup');
var button0Text = Zotero.getString('sync.resetGroupFilesAndSync');
var button1Text = Zotero.getString('sync.skipGroup');
break;
default:
throw new Error("Unsupported library type " + libraryType);
}
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;
return ps.confirmEx(
win,
Zotero.getString('general.permissionDenied'),
msg,
buttonFlags,
button1Text,
button2Text,
null,
null, {}
);
return Zotero.Prompt.confirm({
window: win,
title: Zotero.getString('general.permissionDenied'),
text: msg,
button0: button0Text,
button1: button1Text,
buttonDelay: true,
});
}
}

View file

@ -260,21 +260,15 @@ Zotero.Sync.Server = new function () {
}
}
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ ps.BUTTON_DELAY_ENABLE;
var index = ps.confirmEx(
null,
Zotero.getString('general.warning'),
Zotero.getString('sync.error.writeAccessLost', group.name) + "\n\n"
var index = Zotero.Prompt.confirm({
title: Zotero.getString('general.warning'),
text: Zotero.getString('sync.error.writeAccessLost', group.name) + "\n\n"
+ Zotero.getString('sync.error.groupWillBeReset') + "\n\n"
+ Zotero.getString('sync.error.copyChangedItems'),
buttonFlags,
Zotero.getString('sync.resetGroupAndSync'),
null, null, null, {}
);
button0: Zotero.getString('sync.resetGroupAndSync'),
button1: Zotero.Prompt.BUTTON_TITLE_CANCEL,
buttonDelay: true
});
if (index == 0) {
group.erase();
Zotero.Sync.Server.resetClient();

View file

@ -541,12 +541,6 @@ Zotero.Sync.Runner_Module = function (options = {}) {
let removedGroups = [];
let keptGroups = [];
let ps = Services.prompt;
let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;
// Prompt for each group
//
// TODO: Localize
@ -570,18 +564,16 @@ Zotero.Sync.Runner_Module = function (options = {}) {
msg += "\n\n" + "Would you like to remove it from this computer or keep it "
+ "as a read-only library?";
let index = ps.confirmEx(
null,
"Group Not Found",
msg,
buttonFlags,
"Remove Group",
let index = Zotero.Prompt.confirm({
title: "Group Not Found",
text: msg,
button0: "Remove Group",
// TODO: Any way to have Esc trigger extra1 instead so it doesn't
// have to be in this order?
"Cancel Sync",
"Keep Group",
null, {}
);
button1: "Cancel Sync",
button2: "Keep Group",
buttonDelay: true,
});
if (index == 0) {
removedGroups.push(group);

View file

@ -64,28 +64,21 @@ Zotero.Sync.Data.Utilities = {
[library.name, ZOTERO_CONFIG.DOMAIN_NAME])
+ "\n\n"
+ Zotero.getString('sync.error.groupCopyChangedItems')
var button1Text = Zotero.getString('sync.resetGroupAndSync');
var button2Text = Zotero.getString('sync.skipGroup');
var button0Text = Zotero.getString('sync.resetGroupAndSync');
var button1Text = Zotero.getString('sync.skipGroup');
break;
default:
throw new Error("Unsupported library type " + libraryType);
}
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;
return ps.confirmEx(
win,
Zotero.getString('general.permissionDenied'),
msg,
buttonFlags,
button1Text,
button2Text,
null,
null, {}
);
return Zotero.Prompt.confirm({
window: win,
title: Zotero.getString('general.permissionDenied'),
text: msg,
button0: button0Text,
button1: button1Text,
buttonDelay: true,
});
}
};