fx-compat: Fix app update dialog

Styling needs to be redone, but it works.
This commit is contained in:
Dan Stillman 2022-09-14 02:06:33 -04:00
parent 35d5c2633d
commit dda60995a3
5 changed files with 85 additions and 88 deletions

View file

@ -688,7 +688,7 @@ const ZoteroStandalone = new function() {
* Checks for updates
*/
this.checkForUpdates = function() {
window.open('chrome://mozapps/content/update/updates.xul', 'updateChecker', 'chrome,centerscreen');
window.open('chrome://zotero/content/update/updates.xhtml', 'updateChecker', 'chrome,centerscreen');
}
/**

View file

@ -0,0 +1,35 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
{
Services.scriptloader.loadSubScript("chrome://zotero/content/elements/base.js", this);
const XULElementBaseMixin = MozElements.MozElementMixin(XULElementBase);
class UpdateHeader extends XULElementBaseMixin {
content = MozXULElement.parseXULToFragment(`
<hbox class="wizard-header update-header" flex="1">
<vbox class="wizard-header-box-1">
<vbox class="wizard-header-box-text">
<label class="wizard-header-label"/>
</vbox>
</vbox>
</hbox>
`);
static get inheritedAttributes() {
return {
".wizard-header-label": "value=label",
};
}
connectedCallback() {
super.connectedCallback();
this.initializeAttributeInheritance();
}
}
customElements.define("update-header", UpdateHeader);
}

View file

@ -8,21 +8,14 @@
/* import-globals-from ../../../content/contentAreaUtils.js */
/* globals DownloadUtils, Services, AUSTLMY */
ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm", this);
ChromeUtils.import("resource://gre/modules/Services.jsm", this);
ChromeUtils.import("resource://gre/modules/UpdateTelemetry.jsm", this);
ChromeUtils.defineModuleGetter(
this,
"UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm"
);
const { Zotero } = ChromeUtils.import("chrome://zotero/content/include.jsm");
XPCOMUtils.defineLazyServiceGetter(
this,
"gAUS",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService"
const { DownloadUtils } = ChromeUtils.import(
"resource://gre/modules/DownloadUtils.jsm"
);
const { UpdateUtils } = ChromeUtils.import("resource://gre/modules/UpdateUtils.jsm");
const gAUS = Cc["@mozilla.org/updates/update-service;1"].getService(Ci.nsIApplicationUpdateService);
const XMLNS_XUL =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -35,7 +28,7 @@ const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual";
const URI_UPDATES_PROPERTIES =
"chrome://mozapps/locale/update/updates.properties";
"chrome://zotero/locale/mozilla/updates.properties";
const STATE_DOWNLOADING = "downloading";
const STATE_PENDING = "pending";
@ -72,10 +65,7 @@ var gUpdatesFoundPageId;
* The string to write to the error console..
*/
function LOG(module, string) {
if (gLogEnabled) {
dump("*** AUS:UI " + module + ":" + string + "\n");
Services.console.logStringMessage("AUS:UI " + module + ":" + string);
}
Zotero.debug("AUS:UI " + module + ":" + string);
}
/**
@ -120,15 +110,6 @@ var gUpdates = {
*/
_runUnload: true,
/**
* Submit on close telemtry values for the update wizard.
* @param pageID
* The page id for the last page displayed.
*/
_submitTelemetry(aPageID) {
AUSTLMY.pingWizLastPageCode(aPageID);
},
/**
* Helper function for setButtons
* Resets button to original label & accesskey if string is null.
@ -247,11 +228,10 @@ var gUpdates = {
*/
onWizardFinish() {
this._runUnload = false;
var pageid = document.documentElement.currentPage.pageid;
var pageid = document.querySelector('wizard').currentPage.pageid;
if ("onWizardFinish" in this._pages[pageid]) {
this._pages[pageid].onWizardFinish();
}
this._submitTelemetry(pageid);
},
/**
@ -260,11 +240,10 @@ var gUpdates = {
*/
onWizardCancel() {
this._runUnload = false;
var pageid = document.documentElement.currentPage.pageid;
var pageid = document.querySelector('wizard').currentPage.pageid;
if ("onWizardCancel" in this._pages[pageid]) {
this._pages[pageid].onWizardCancel();
}
this._submitTelemetry(pageid);
},
/**
@ -272,7 +251,7 @@ var gUpdates = {
* the function call to the selected page.
*/
onWizardNext() {
var cp = document.documentElement.currentPage;
var cp = document.querySelector('wizard').currentPage;
if (!cp) {
return;
}
@ -310,7 +289,7 @@ var gUpdates = {
* Called when the wizard UI is loaded.
*/
onLoad() {
this.wiz = document.documentElement;
this.wiz = document.querySelector('wizard');
gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false);
@ -427,6 +406,9 @@ var gUpdates = {
gFinishedPage.onExtra2();
});
// Hide default wizard header ("Introduction")
gUpdates.wiz.shadowRoot.querySelector('.wizard-header').hidden = true;
// Advance to the Start page.
this.getStartPageID(function(startPageID) {
LOG(
@ -633,8 +615,8 @@ var gCheckingPage = {
/**
* See nsIUpdateCheckListener
*/
onCheckComplete(request, updates, updateCount) {
gUpdates.setUpdate(gAUS.selectUpdate(updates, updates.length));
async onCheckComplete(request, updates) {
gUpdates.setUpdate(gAUS.selectUpdate(updates));
if (gUpdates.update) {
LOG("gCheckingPage", "onCheckComplete - update found");
if (gUpdates.update.unsupported) {
@ -666,7 +648,7 @@ var gCheckingPage = {
/**
* See nsIUpdateCheckListener
*/
onError(request, update) {
async onError(request, update) {
LOG("gCheckingPage", "onError - proceeding to error page");
gUpdates.setUpdate(update);
gUpdates.wiz.goTo("errors");
@ -1210,7 +1192,7 @@ var gErrorExtraPage = {
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
}
document.getElementById("genericBackgroundErrorLabel").hidden = false;
document.getElementById("bgErrorLabel").hidden = false;
let manualURL = Services.urlFormatter.formatURLPref(
PREF_APP_UPDATE_URL_MANUAL
);

View file

@ -5,20 +5,16 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/content/update/updates.css"?>
<?xml-stylesheet href="chrome://mozapps/skin/update/updates.css"?>
<?xml-stylesheet href="chrome://zotero/content/update/updates.css"?>
<!DOCTYPE wizard [
<!ENTITY % updateDTD SYSTEM "chrome://mozapps/locale/update/updates.dtd">
<!ENTITY % updateDTD SYSTEM "chrome://zotero/locale/mozilla/updates.dtd">
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%updateDTD;
%brandDTD;
#if defined(XP_MACOSX) && MOZ_BUILD_APP == browser
#include ../../../../browser/base/content/browser-doctype.inc
#endif
]>
<wizard id="updates"
<window id="updates"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="&updateWizard.title;"
@ -27,25 +23,30 @@
onload="gUpdates.onLoad();"
onunload="gUpdates.onUnload();">
<script src="chrome://global/content/contentAreaUtils.js"/>
<script src="chrome://mozapps/content/update/updates.js"/>
<script src="chrome://global/content/globalOverlay.js"/>
<script src="chrome://global/content/editMenuOverlay.js"/>
#if defined(XP_MACOSX) && MOZ_BUILD_APP == browser
#include ../../../../browser/base/content/macWindow.inc.xul
#endif
<script src="chrome://global/content/customElements.js"/>
<script src="chrome://global/content/contentAreaUtils.js"/>
<script src="chrome://global/content/globalOverlay.js"/>
<script src="chrome://zotero/content/editMenuOverlay.js"/>
<script src="chrome://zotero/content/update/updates.js"/>
<script src="chrome://zotero/content/update/update-header.js"/>
<wizard>
<linkset>
<html:link rel="localization" href="toolkit/global/wizard.ftl"/>
</linkset>
<stringbundleset id="updateSet">
<stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
<stringbundle id="updateStrings" src="chrome://mozapps/locale/update/updates.properties"/>
<stringbundle id="updateStrings" src="chrome://zotero/locale/mozilla/updates.properties"/>
</stringbundleset>
<wizardpage id="dummy" pageid="dummy" firstpage="true"/>
<!-- Disabled to prevent wizard accessMethod from being set to 'sequential'
due to lack of "next" attribute. Unclear how this worked in Firefox... -->
<!--<wizardpage id="dummy" pageid="dummy" firstpage="true"/>-->
<wizardpage id="checking" pageid="checking" next="noupdatesfound"
object="gCheckingPage">
<updateheader label="&checking.title;"/>
<update-header label="&checking.title;"/>
<vbox class="update-content" flex="1">
<label>&updateCheck.label;</label>
<separator class="thin"/>
@ -55,7 +56,7 @@
<wizardpage id="noupdatesfound" pageid="noupdatesfound"
object="gNoUpdatesPage">
<updateheader label="&noupdatesfound.title;"/>
<update-header label="&noupdatesfound.title;"/>
<vbox class="update-content" flex="1">
<label id="noUpdatesAutoEnabled" hidden="true">&noupdatesautoenabled.intro;</label>
<label id="noUpdatesAutoDisabled" hidden="true">&noupdatesautodisabled.intro;</label>
@ -63,7 +64,7 @@
</wizardpage>
<wizardpage id="manualUpdate" pageid="manualUpdate" object="gManualUpdatePage">
<updateheader label="&manualUpdate.title;"/>
<update-header label="&manualUpdate.title;"/>
<vbox class="update-content" flex="1">
<label id="manualUpdateDesc">&manualUpdate.desc;</label>
<label id="manualUpdateSpaceDesc"
@ -79,7 +80,7 @@
<wizardpage id="unsupported" pageid="unsupported"
object="gUnsupportedPage">
<updateheader label="&unsupported.title;"/>
<update-header label="&unsupported.title;"/>
<vbox class="update-content" flex="1">
<description flex="1">&unsupported.label;
<label id="unsupportedLinkLabel" class="inline-link" onclick="openUpdateURL(event);" is="text-link">
@ -91,7 +92,7 @@
<wizardpage id="updatesfoundbasic" pageid="updatesfoundbasic"
object="gUpdatesFoundBasicPage" next="downloading">
<updateheader id="updatesFoundBasicHeader" label=""/>
<update-header id="updatesFoundBasicHeader" label=""/>
<vbox class="update-content" flex="1">
<label id="updatesFoundInto"/>
<separator class="thin"/>
@ -110,7 +111,7 @@
<wizardpage id="downloading" pageid="downloading"
object="gDownloadingPage">
<updateheader label="&downloadPage.title;"/>
<update-header label="&downloadPage.title;"/>
<vbox class="update-content" flex="1">
<hbox id="downloadStatusProgress">
<html:progress id="downloadProgress" max="100"/>
@ -128,7 +129,7 @@
</wizardpage>
<wizardpage id="errors" pageid="errors" object="gErrorsPage">
<updateheader label="&error.title;"/>
<update-header label="&error.title;"/>
<vbox class="update-content" flex="1">
<label id="errorIntro">&error.label;</label>
<separator/>
@ -144,7 +145,7 @@
<wizardpage id="errorextra" pageid="errorextra"
object="gErrorExtraPage">
<updateheader label="&error.title;"/>
<update-header label="&error.title;"/>
<vbox class="update-content" flex="1">
<label id="bgErrorLabel">&genericBackgroundError.label;</label>
<hbox>
@ -156,14 +157,14 @@
<wizardpage id="errorpatching" pageid="errorpatching" next="downloading"
object="gErrorPatchingPage">
<updateheader label="&error.title;"/>
<update-header label="&error.title;"/>
<vbox class="update-content" flex="1">
<label>&errorpatching.intro;</label>
</vbox>
</wizardpage>
<wizardpage id="finished" pageid="finished" object="gFinishedPage">
<updateheader label="&finishedPage.title;"/>
<update-header label="&finishedPage.title;"/>
<vbox class="update-content" flex="1">
<label>&finishedPage.text;</label>
</vbox>
@ -171,7 +172,7 @@
<wizardpage id="finishedBackground" pageid="finishedBackground"
object="gFinishedPage">
<updateheader label="&finishedPage.title;"/>
<update-header label="&finishedPage.title;"/>
<vbox class="update-content" flex="1">
<label>&finishedBackgroundPage.text;</label>
<separator/>
@ -195,3 +196,4 @@
</wizardpage>
</wizard>
</window>

View file

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings id="updatesBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="updateheader">
<content>
<xul:hbox class="wizard-header update-header" flex="1">
<xul:vbox class="wizard-header-box-1">
<xul:vbox class="wizard-header-box-text">
<xul:label class="wizard-header-label" xbl:inherits="value=label"/>
</xul:vbox>
</xul:vbox>
</xul:hbox>
</content>
</binding>
</bindings>