Bug 1762775 - Change download folder display in prefs UI. r=Gijs,fluent-reviewers,preferences-reviewers,desktop-theme-reviewers,dao,flod

The default download folder prefs are now counterintuitively used
whether browser.download.useDownloadDir is enabled or not, since we no
longer save downloads to the "temp" folder. But the display for these
prefs in about:preferences makes it seem as though the configured path
will not be used if the "Always ask..." option is selected. This patch
removes the radiogroup and replaces it with a checkbox, so that the
download folder path can be changed irrespective of useDownloadDir's
value (unless browser.download.dir is disabled by policy).

Differential Revision: https://phabricator.services.mozilla.com/D143555
This commit is contained in:
Shane Hughes 2022-04-28 19:49:17 +00:00
Родитель 6028a138e9
Коммит d148fe50bc
6 изменённых файлов: 60 добавлений и 56 удалений

Просмотреть файл

@ -17,16 +17,6 @@ add_task(async function test_defaultdownload() {
true, true,
"alwaysAsk should be disabled." "alwaysAsk should be disabled."
); );
is(
browser.contentDocument.getElementById("saveTo").selected,
true,
"saveTo should be selected."
);
is(
browser.contentDocument.getElementById("saveTo").disabled,
true,
"saveTo should be disabled."
);
let home = Services.dirsvc.get("Home", Ci.nsIFile).path; let home = Services.dirsvc.get("Home", Ci.nsIFile).path;
is( is(
Services.prefs.getStringPref("browser.download.dir"), Services.prefs.getStringPref("browser.download.dir"),
@ -59,16 +49,6 @@ add_task(async function test_download() {
true, true,
"alwaysAsk should be disabled." "alwaysAsk should be disabled."
); );
is(
browser.contentDocument.getElementById("saveTo").selected,
true,
"saveTo should be selected."
);
is(
browser.contentDocument.getElementById("saveTo").disabled,
true,
"saveTo should be disabled."
);
is( is(
browser.contentDocument.getElementById("downloadFolder").disabled, browser.contentDocument.getElementById("downloadFolder").disabled,
true, true,

Просмотреть файл

@ -410,25 +410,23 @@
<groupbox id="downloadsGroup" data-category="paneGeneral" hidden="true"> <groupbox id="downloadsGroup" data-category="paneGeneral" hidden="true">
<label><html:h2 data-l10n-id="download-header"/></label> <label><html:h2 data-l10n-id="download-header"/></label>
<radiogroup id="saveWhere" <hbox id="saveWhere">
preference="browser.download.useDownloadDir"> <label id="saveTo"
<hbox> control="downloadFolder"
<radio id="saveTo" data-l10n-id="download-save-where"/>
value="true" <html:input id="downloadFolder"
data-l10n-id="download-save-to"/> type="text"
<html:input id="downloadFolder" readonly="readonly"
type="text" aria-labelledby="saveTo"/>
readonly="readonly" <button id="chooseFolder"
aria-labelledby="saveTo"/> is="highlightable-button"
<button id="chooseFolder" class="accessory-button"
is="highlightable-button" data-l10n-id="download-choose-folder"/>
class="accessory-button" </hbox>
data-l10n-id="download-choose-folder"/> <checkbox id="alwaysAsk"
</hbox> value="false"
<radio id="alwaysAsk" data-l10n-id="download-always-ask-where"
value="false" preference="browser.download.useDownloadDir"/>
data-l10n-id="download-always-ask-where"/>
</radiogroup>
</groupbox> </groupbox>
<groupbox id="applicationsGroup" data-category="paneGeneral" hidden="true"> <groupbox id="applicationsGroup" data-category="paneGeneral" hidden="true">

Просмотреть файл

@ -786,7 +786,7 @@ var gMainPane = {
() => this.writeCheckSpelling() () => this.writeCheckSpelling()
); );
Preferences.addSyncFromPrefListener( Preferences.addSyncFromPrefListener(
document.getElementById("saveWhere"), document.getElementById("alwaysAsk"),
() => this.readUseDownloadDir() () => this.readUseDownloadDir()
); );
Preferences.addSyncFromPrefListener( Preferences.addSyncFromPrefListener(
@ -2936,22 +2936,18 @@ var gMainPane = {
*/ */
/** /**
* Enables/disables the folder field and Browse button based on whether a * Disables the downloads folder field and Browse button if the default
* default download directory is being used. * download directory pref is locked (e.g., by the DownloadDirectory or
* DefaultDownloadDirectory policies)
*/ */
readUseDownloadDir() { readUseDownloadDir() {
var downloadFolder = document.getElementById("downloadFolder"); document.getElementById(
var chooseFolder = document.getElementById("chooseFolder"); "downloadFolder"
var useDownloadDirPreference = Preferences.get( ).disabled = document.getElementById(
"browser.download.useDownloadDir" "chooseFolder"
); ).disabled = document.getElementById("saveTo").disabled =
var dirPreference = Preferences.get("browser.download.dir"); Preferences.get("browser.download.dir").locked ||
Preferences.get("browser.download.folderList").locked;
downloadFolder.disabled =
!useDownloadDirPreference.value || dirPreference.locked;
chooseFolder.disabled =
!useDownloadDirPreference.value || dirPreference.locked;
// don't override the preference's value in UI // don't override the preference's value in UI
return undefined; return undefined;
}, },

Просмотреть файл

@ -339,8 +339,7 @@ files-and-applications-title = Files and Applications
download-header = Downloads download-header = Downloads
download-save-to = download-save-where = Save files to
.label = Save files to
.accesskey = v .accesskey = v
download-choose-folder = download-choose-folder =

Просмотреть файл

@ -331,6 +331,14 @@ checkbox {
padding: 0.3em; padding: 0.3em;
} }
#saveWhere {
-moz-box-align: center;
}
#saveTo {
margin-inline-end: 1em;
}
#downloadFolder { #downloadFolder {
-moz-box-flex: 1; -moz-box-flex: 1;
margin-block: 4px; margin-block: 4px;

Просмотреть файл

@ -0,0 +1,23 @@
# coding=utf8
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from __future__ import absolute_import
from fluent.migrate.helpers import transforms_from
from fluent.migrate import COPY_PATTERN
def migrate(ctx):
"""Bug 1762775 - download folder picker should be available all the time, part {index}"""
ctx.add_transforms(
"browser/browser/preferences/preferences.ftl",
"browser/browser/preferences/preferences.ftl",
transforms_from(
"""
download-save-where = { COPY_PATTERN(from_path, "download-save-to.label") }
.accesskey = { COPY_PATTERN(from_path, "download-save-to.accesskey") }
""",
from_path="browser/browser/preferences/preferences.ftl",
),
)