mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1520924 - Remove 'update' XBL binding and convert strings to Fluent. r=paolo,flod
Differential Revision: https://phabricator.services.mozilla.com/D16982 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
22c90af654
commit
a41077218e
@ -140,14 +140,38 @@ add_task(async function() {
|
||||
for (let i = 0; i < updates.length; ++i) {
|
||||
update = updates[i];
|
||||
updateData = mockUpdateManager.getUpdateAt(i);
|
||||
const l10nAttrs = frameDoc.l10n.getAttributes(update);
|
||||
Assert.deepEqual(l10nAttrs, {
|
||||
id: "update-full-name",
|
||||
args: { name: updateData.name, buildID: updateData.buildID },
|
||||
}, "Wrong update name");
|
||||
is(update.installDate, formatInstallDate(updateData.installDate), "Wrong update installDate");
|
||||
is(update.detailsURL, updateData.detailsURL, "Wrong update detailsURL");
|
||||
is(update.status, updateData.statusText, "Wrong update status");
|
||||
|
||||
let testcases = [
|
||||
{
|
||||
selector: ".update-name",
|
||||
id: "update-full-build-name",
|
||||
args: { name: updateData.name, buildID: updateData.buildID },
|
||||
},
|
||||
{
|
||||
selector: ".update-installedOn-label",
|
||||
id: "update-installed-on",
|
||||
args: { date: formatInstallDate(updateData.installDate) },
|
||||
},
|
||||
{
|
||||
selector: ".update-status-label",
|
||||
id: "update-status",
|
||||
args: { status: updateData.statusText },
|
||||
}
|
||||
];
|
||||
|
||||
for (let {selector, id, args} of testcases) {
|
||||
const element = update.querySelector(selector);
|
||||
const l10nAttrs = frameDoc.l10n.getAttributes(element);
|
||||
Assert.deepEqual(l10nAttrs, {
|
||||
id,
|
||||
args,
|
||||
}, "Wrong " + id);
|
||||
}
|
||||
|
||||
if (update.detailsURL) {
|
||||
is(update.detailsURL, update.querySelector(".text-link").href,
|
||||
"Wrong detailsURL");
|
||||
}
|
||||
}
|
||||
|
||||
// Test the dialog window closes
|
||||
|
64
python/l10n/fluent_migrations/bug_1520924_updateHistory.py
Normal file
64
python/l10n/fluent_migrations/bug_1520924_updateHistory.py
Normal file
@ -0,0 +1,64 @@
|
||||
# coding=utf8
|
||||
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
from __future__ import absolute_import
|
||||
import fluent.syntax.ast as FTL
|
||||
from fluent.migrate.helpers import transforms_from
|
||||
from fluent.migrate.helpers import VARIABLE_REFERENCE
|
||||
from fluent.migrate import COPY, CONCAT, REPLACE
|
||||
|
||||
|
||||
def migrate(ctx):
|
||||
"""Bug 1520924 - Remove 'update' XBL binding and convert strings to Fluent, part {index}."""
|
||||
|
||||
ctx.add_transforms(
|
||||
"toolkit/toolkit/updates/history.ftl",
|
||||
"toolkit/toolkit/updates/history.ftl",
|
||||
transforms_from(
|
||||
"""
|
||||
update-details = { COPY("toolkit/chrome/mozapps/update/updates.dtd", "update.details.label") }
|
||||
""")
|
||||
)
|
||||
|
||||
ctx.add_transforms(
|
||||
"toolkit/toolkit/updates/history.ftl",
|
||||
"toolkit/toolkit/updates/history.ftl",
|
||||
[
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("update-full-build-name"),
|
||||
value=REPLACE(
|
||||
"toolkit/chrome/mozapps/update/updates.properties",
|
||||
"updateFullName",
|
||||
{
|
||||
"%1$S": VARIABLE_REFERENCE("name"),
|
||||
"%2$S": VARIABLE_REFERENCE("buildID"),
|
||||
},
|
||||
normalize_printf=True
|
||||
)
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("update-installed-on"),
|
||||
value=CONCAT(
|
||||
COPY(
|
||||
"toolkit/chrome/mozapps/update/updates.dtd",
|
||||
"update.installedOn.label"
|
||||
),
|
||||
FTL.TextElement(" "),
|
||||
VARIABLE_REFERENCE("date"),
|
||||
),
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("update-status"),
|
||||
value=CONCAT(
|
||||
COPY(
|
||||
"toolkit/chrome/mozapps/update/updates.dtd",
|
||||
"update.status.label"
|
||||
),
|
||||
FTL.TextElement(" "),
|
||||
VARIABLE_REFERENCE("status"),
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
@ -72,6 +72,3 @@
|
||||
&brandShortName; now, continue working and restart later, or decline this
|
||||
update.">
|
||||
|
||||
<!ENTITY update.details.label "Details">
|
||||
<!ENTITY update.installedOn.label "Installed on:">
|
||||
<!ENTITY update.status.label "Status:">
|
||||
|
@ -20,5 +20,8 @@ state-header = State
|
||||
# Variables:
|
||||
# $name (String): name of the update
|
||||
# $buildID (String): build identifier from the local updates.xml
|
||||
update-full-name =
|
||||
.name = { $name } ({ $buildID })
|
||||
update-full-build-name = { $name } ({ $buildID })
|
||||
|
||||
update-details = Details
|
||||
update-installed-on = Installed on: { $date }
|
||||
update-status = Status: { $status }
|
||||
|
@ -33,15 +33,38 @@ var gUpdateHistory = {
|
||||
|
||||
var element = document.createXULElement("richlistitem");
|
||||
element.className = "update";
|
||||
|
||||
const topLine = document.createXULElement("hbox");
|
||||
const nameLabel = document.createXULElement("label");
|
||||
nameLabel.className = "update-name";
|
||||
document.l10n.setAttributes(nameLabel, "update-full-build-name", {
|
||||
name: update.name,
|
||||
buildID: update.buildID,
|
||||
});
|
||||
topLine.appendChild(nameLabel);
|
||||
|
||||
if (update.detailsURL) {
|
||||
const detailsLink = document.createXULElement("label");
|
||||
detailsLink.className = "text-link";
|
||||
detailsLink.href = update.detailsURL;
|
||||
document.l10n.setAttributes(detailsLink, "update-details");
|
||||
topLine.appendChild(detailsLink);
|
||||
}
|
||||
|
||||
const installedOnLabel = document.createXULElement("label");
|
||||
installedOnLabel.className = "update-installedOn-label";
|
||||
document.l10n.setAttributes(installedOnLabel, "update-installed-on", {
|
||||
date: this._formatDate(update.installDate),
|
||||
});
|
||||
|
||||
const statusLabel = document.createXULElement("label");
|
||||
statusLabel.className = "update-status-label";
|
||||
document.l10n.setAttributes(statusLabel, "update-status", {
|
||||
status: update.statusText,
|
||||
});
|
||||
|
||||
element.append(topLine, installedOnLabel, statusLabel);
|
||||
this._view.appendChild(element);
|
||||
element.setAttribute("data-l10n-attrs", "name");
|
||||
document.l10n.setAttributes(element, "update-full-name", { name: update.name, buildID: update.buildID});
|
||||
element.installDate = this._formatDate(update.installDate);
|
||||
if (update.detailsURL)
|
||||
element.detailsURL = update.detailsURL;
|
||||
else
|
||||
element.hideDetailsURL = true;
|
||||
element.status = update.statusText;
|
||||
}
|
||||
}
|
||||
var cancelbutton = document.documentElement.getButton("cancel");
|
||||
@ -61,4 +84,3 @@ var gUpdateHistory = {
|
||||
return date.toLocaleString(undefined, dtOptions);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,10 @@ updateheader {
|
||||
|
||||
/* Update History Window */
|
||||
richlistitem.update {
|
||||
-moz-binding: url("chrome://mozapps/content/update/updates.xml#update");
|
||||
display: -moz-box;
|
||||
-moz-box-orient: vertical;
|
||||
}
|
||||
|
||||
.update-name {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
@ -3,9 +3,6 @@
|
||||
- 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/. -->
|
||||
|
||||
|
||||
<!DOCTYPE bindings SYSTEM "chrome://mozapps/locale/update/updates.dtd">
|
||||
|
||||
<bindings id="updatesBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
@ -22,51 +19,4 @@
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="update" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||
<content>
|
||||
<xul:hbox>
|
||||
<xul:label class="update-name" xbl:inherits="value=name" flex="1" crop="right"/>
|
||||
<xul:label xbl:inherits="href=detailsURL,hidden=hideDetailsURL" class="text-link"
|
||||
value="&update.details.label;"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox>
|
||||
<xul:label class="update-installedOn-label">&update.installedOn.label;</xul:label>
|
||||
<xul:label class="update-installedOn-value" flex="1"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox>
|
||||
<xul:label class="update-status-label">&update.status.label;</xul:label>
|
||||
<xul:description class="update-status-value" flex="1"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
<implementation>
|
||||
<property name="name"
|
||||
onget="return this.getAttribute('name');"
|
||||
onset="this.setAttribute('name', val); return val;"/>
|
||||
<property name="detailsURL"
|
||||
onget="return this.getAttribute('detailsURL');"
|
||||
onset="this.setAttribute('detailsURL', val); return val;"/>
|
||||
<property name="installDate"
|
||||
onget="return this.getAttribute('installDate');">
|
||||
<setter><![CDATA[
|
||||
this.setAttribute("installDate", val);
|
||||
var field = document.getAnonymousElementByAttribute(this, "class", "update-installedOn-value");
|
||||
field.textContent = val;
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
<property name="hideDetailsURL"
|
||||
onget="return this.getAttribute('hideDetailsURL');"
|
||||
onset="this.setAttribute('hideDetailsURL', val); return val;"/>
|
||||
<property name="status"
|
||||
onget="return this.getAttribute('status');">
|
||||
<setter><![CDATA[
|
||||
this.setAttribute("status", val);
|
||||
var field = document.getAnonymousElementByAttribute(this, "class", "update-status-value");
|
||||
field.textContent = val;
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
Loading…
Reference in New Issue
Block a user