Bug 1689378: update recently closed windows and tabs panels r=mconley,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D103962
This commit is contained in:
Emma Malysz 2021-02-09 01:08:38 +00:00
parent bfc8d66755
commit 4f87b662a9
6 changed files with 36 additions and 19 deletions

View File

@ -731,7 +731,9 @@ HistoryMenu.prototype = {
// populate menu
let tabsFragment = RecentlyClosedTabsAndWindowsMenuUtils.getTabsFragment(
window,
"menuitem"
"menuitem",
/* aPrefixRestoreAll = */ false,
"menu-history-reopen-all-tabs"
);
undoPopup.appendChild(tabsFragment);
},
@ -769,7 +771,9 @@ HistoryMenu.prototype = {
// populate menu
let windowsFragment = RecentlyClosedTabsAndWindowsMenuUtils.getWindowsFragment(
window,
"menuitem"
"menuitem",
/* aPrefixRestoreAll = */ false,
"menu-history-reopen-all-windows"
);
undoPopup.appendChild(windowsFragment);
},

View File

@ -186,19 +186,23 @@ const CustomizableWidgets = [
let body = document.createXULElement("vbox");
body.className = "panel-subview-body";
body.appendChild(fragment);
let separator = document.createXULElement("toolbarseparator");
let footer;
while (--elementCount >= 0) {
let element = body.children[elementCount];
CustomizableUI.addShortcut(element);
element.classList.add("subviewbutton");
if (element.classList.contains("restoreallitem")) {
footer = element;
element.classList.add("panel-subview-footer");
element.classList.add(
"subviewbutton-iconic",
"panel-subview-footer-button"
);
} else {
element.classList.add("subviewbutton-iconic", "bookmark-item");
}
}
panelview.appendChild(body);
panelview.appendChild(separator);
panelview.appendChild(footer);
},
},

View File

@ -31,7 +31,7 @@ var RecentlyClosedTabsAndWindowsMenuUtils = {
* @param aPrefixRestoreAll (defaults to false)
* Whether the 'restore all tabs' item is suffixed or prefixed to the list.
* If suffixed (the default) a separator will be inserted before it.
* @param aRestoreAllLabel (defaults to "menuRestoreAllTabs.label")
* @param aRestoreAllLabel (defaults to "appmenu-reopen-all-tabs")
* Which localizable string to use for the 'restore all tabs' item.
* @returns A document fragment with UI items for each recently closed tab.
*/
@ -39,7 +39,7 @@ var RecentlyClosedTabsAndWindowsMenuUtils = {
aWindow,
aTagName,
aPrefixRestoreAll = false,
aRestoreAllLabel = "menuRestoreAllTabs.label"
aRestoreAllLabel = "appmenu-reopen-all-tabs"
) {
let doc = aWindow.document;
let fragment = doc.createDocumentFragment();
@ -79,7 +79,7 @@ var RecentlyClosedTabsAndWindowsMenuUtils = {
* @param aPrefixRestoreAll (defaults to false)
* Whether the 'restore all windows' item is suffixed or prefixed to the list.
* If suffixed (the default) a separator will be inserted before it.
* @param aRestoreAllLabel (defaults to "menuRestoreAllWindows.label")
* @param aRestoreAllLabel (defaults to "appmenu-reopen-all-windows")
* Which localizable string to use for the 'restore all windows' item.
* @returns A document fragment with UI items for each recently closed window.
*/
@ -87,7 +87,7 @@ var RecentlyClosedTabsAndWindowsMenuUtils = {
aWindow,
aTagName,
aPrefixRestoreAll = false,
aRestoreAllLabel = "menuRestoreAllWindows.label"
aRestoreAllLabel = "appmenu-reopen-all-windows"
) {
let closedWindowData = SessionStore.getClosedWindowData(false);
let doc = aWindow.document;
@ -146,6 +146,14 @@ var RecentlyClosedTabsAndWindowsMenuUtils = {
ancestorPanel.hidePopup();
}
},
get strings() {
delete this.strings;
return (this.strings = new Localization(
["branding/brand.ftl", "browser/menubar.ftl", "browser/appmenu.ftl"],
true
));
},
};
function setImage(aItem, aElement) {
@ -221,12 +229,6 @@ function createEntry(
RecentlyClosedTabsAndWindowsMenuUtils._undoCloseMiddleClick
);
}
if (aIndex == 0) {
element.setAttribute(
"key",
"key_undoClose" + (aIsWindowsFragment ? "Window" : "Tab")
);
}
aFragment.appendChild(element);
}
@ -260,10 +262,16 @@ function createRestoreAllEntry(
) {
let restoreAllElements = aDocument.createXULElement(aTagName);
restoreAllElements.classList.add("restoreallitem");
// We cannot use aDocument.l10n.setAttributes because the menubar label is not
// updated in time and displays a blank string (see Bug 1691553).
restoreAllElements.setAttribute(
"label",
navigatorBundle.GetStringFromName(aRestoreAllLabel)
RecentlyClosedTabsAndWindowsMenuUtils.strings.formatValueSync(
aRestoreAllLabel
)
);
restoreAllElements.setAttribute(
"oncommand",
"for (var i = 0; i < " +

View File

@ -116,6 +116,8 @@ profiler-popup-capture-shortcut =
appmenu-manage-history =
.label = Manage History
appmenu-reopen-all-tabs = Reopen All Tabs
appmenu-reopen-all-windows = Reopen All Windows
## Help panel
appmenu-help-header =

View File

@ -209,6 +209,8 @@ menu-history-undo-menu =
.label = Recently Closed Tabs
menu-history-undo-window-menu =
.label = Recently Closed Windows
menu-history-reopen-all-tabs = Reopen All Tabs
menu-history-reopen-all-windows = Reopen All Windows
## Bookmarks Menu

View File

@ -340,11 +340,8 @@ update.downloadAndInstallButton.accesskey=U
menuOpenAllInTabs.label=Open All in Tabs
# History menu
menuRestoreAllTabs.label=Restore All Tabs
# LOCALIZATION NOTE (menuRestoreAllWindows, menuUndoCloseWindowLabel, menuUndoCloseWindowSingleTabLabel):
# see bug 394759
menuRestoreAllWindows.label=Restore All Windows
# LOCALIZATION NOTE (menuUndoCloseWindowLabel): Semicolon-separated list of plural forms.
# see bug 394759
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 Window Title, #2 Number of tabs
menuUndoCloseWindowLabel=#1 (and #2 other tab);#1 (and #2 other tabs)