Bug 1239848 - Revert ProfileManager changes until a better UX/UI is ready, r=ehsan

This commit is contained in:
Andrea Marchesini 2016-01-20 09:16:49 +00:00
parent 45039802b8
commit c3ee54f07c
10 changed files with 338 additions and 69 deletions

View File

@ -17,8 +17,6 @@ XPCOMUtils.defineLazyServiceGetter(
'nsIToolkitProfileService'
);
const gManage = window.location.href.indexOf('?manage') != -1;
const bundle = Services.strings.createBundle(
'chrome://global/locale/aboutProfiles.properties');
@ -54,24 +52,8 @@ function findCurrentProfile() {
}
function initializeUI() {
if (gManage) {
document.getElementById('about-profile-action-box').style.display = 'none';
document.getElementById('profile-manager-action-box').style.display = 'block';
let autoSelect = document.getElementById("auto-select");
autoSelect.checked = ProfileService.startWithLastProfile;
autoSelect.addEventListener('change', function() {
ProfileService.startWithLastProfile = autoSelect.checked;
});
let offline = document.getElementById("work-offline");
offline.addEventListener('change', function() {
ProfileService.startOffline = offline.checked;
});
} else {
document.getElementById('about-profile-action-box').style.display = 'block';
document.getElementById('profile-manager-action-box').style.display = 'none';
}
document.getElementById('about-profile-action-box').style.display = 'block';
document.getElementById('profile-manager-action-box').style.display = 'none';
refreshUI();
}
@ -122,33 +104,11 @@ function display(profileData) {
let nameStr = bundle.formatStringFromName('name', [profileData.profile.name], 1);
let name = document.createElement('h2');
if (gManage) {
let checkBox = document.createElement('input');
checkBox.setAttribute('type', 'radio');
checkBox.setAttribute('name', 'profile');
checkBox.setAttribute('id', profileData.profile.name);
if (profileData.isCurrentProfile) {
checkBox.setAttribute('checked', 'checked');
}
name.appendChild(checkBox);
checkBox.addEventListener('change', function() {
ProfileService.selectedProfile = profileData.profile;
ProfileService.flush();
});
let label = document.createElement('label');
label.appendChild(document.createTextNode(nameStr));
label.setAttribute('for', profileData.profile.name);
name.appendChild(label);
} else {
name.appendChild(document.createTextNode(nameStr));
}
name.appendChild(document.createTextNode(nameStr));
div.appendChild(name);
if (!gManage && profileData.isCurrentProfile) {
if (profileData.isCurrentProfile) {
let currentProfile = document.createElement('h3');
let currentProfileStr = bundle.GetStringFromName('currentProfile');
currentProfile.appendChild(document.createTextNode(currentProfileStr));
@ -209,7 +169,7 @@ function display(profileData) {
};
div.appendChild(renameButton);
if (gManage || !profileData.isCurrentProfile) {
if (!profileData.isCurrentProfile) {
let removeButton = document.createElement('button');
removeButton.appendChild(document.createTextNode(bundle.GetStringFromName('remove')));
removeButton.onclick = function() {

View File

@ -17,7 +17,6 @@ currentProfile = This is the profile in use and it cannot be deleted.
rename = Rename
remove = Remove
setAsDefault = Set as default profile
open = Open
yes = yes
no = no

View File

@ -7,5 +7,25 @@
<!ENTITY windowtitle.label "&brandShortName; - Choose User Profile">
<!ENTITY profilename.label "Profile Name:">
<!ENTITY start.label "Start &brandShortName;">
<!ENTITY exit.label "Exit">
<!ENTITY availprofiles.label "Available Profiles">
<!ENTITY newButton.label "Create Profile…">
<!ENTITY newButton.accesskey "C">
<!ENTITY renameButton.label "Rename Profile…">
<!ENTITY renameButton.accesskey "R">
<!ENTITY deleteButton.label "Delete Profile…">
<!ENTITY deleteButton.accesskey "D">
<!-- manager entities -->
<!ENTITY pmDescription.label "&brandShortName; stores information about your settings, preferences, and other user items in your user profile.">
<!ENTITY offlineState.label "Work offline">
<!ENTITY offlineState.accesskey "o">
<!ENTITY useSelected.label "Use the selected profile without asking at startup">
<!ENTITY useSelected.accesskey "s">

View File

@ -13,13 +13,30 @@ restartMessageNoUnlockerMac=A copy of %S is already open. Only one copy of %S ca
restartMessageUnlockerMac=A copy of %S is already open. The running copy of %S will quit in order to open this one.
# Profile manager
# LOCALIZATION NOTE (profileTooltip): First %S is the profile name, second %S is the path to the profile folder.
profileTooltip=Profile: '%S' - Path: '%S'
pleaseSelectTitle=Select Profile
pleaseSelect=Please select a profile to begin %S, or create a new profile.
profileLockedTitle=Profile In Use
profileLocked2=%S cannot use the profile "%S" because it is in use.\n\nTo continue, close the running instance of %S or choose a different profile.
renameProfileTitle=Rename Profile
renameProfilePrompt=Rename the profile "%S" to:
profileNameInvalidTitle=Invalid profile name
profileNameInvalid=The profile name "%S" is not allowed.
chooseFolder=Choose Profile Folder
profileNameEmpty=An empty profile name is not allowed.
invalidChar=The character "%S" is not allowed in profile names. Please choose a different name.
deleteTitle=Delete Profile
deleteProfileConfirm=Deleting a profile will remove the profile from the list of available profiles and cannot be undone.\nYou may also choose to delete the profile data files, including your settings, certificates and other user-related data. This option will delete the folder "%S" and cannot be undone.\nWould you like to delete the profile data files?
deleteFiles=Delete Files
dontDeleteFiles=Don't Delete Files
profileCreationFailed=Profile couldn't be created. Probably the chosen folder isn't writable.
profileCreationFailedTitle=Profile Creation failed
profileExists=A profile with this name already exists. Please choose another name.
@ -28,8 +45,6 @@ profileFinishText=Click Finish to create this new profile.
profileFinishTextMac=Click Done to create this new profile.
profileMissing=Your %S profile cannot be loaded. It may be missing or inaccessible.
profileMissingTitle=Profile Missing
pleaseSelectTitle=Select Profile
pleaseSelect=Please select a profile to begin %S, or create a new profile.
# Profile reset
# LOCALIZATION NOTE (resetBackupDirectory): Directory name for the profile directory backup created during reset. This directory is placed in a location users will see it (ie. their desktop). %S is the application name.

View File

@ -4,10 +4,11 @@
* 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/. */
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const C = Components.classes;
const I = Components.interfaces;
const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1";
@ -18,22 +19,57 @@ var gProfileService;
function startup()
{
gDialogParams = window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
try {
gDialogParams = window.arguments[0].
QueryInterface(I.nsIDialogParamBlock);
gProfileService = Cc[ToolkitProfileService].getService(Ci.nsIToolkitProfileService);
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
gProfileManagerBundle = document.getElementById("bundle_profileManager");
gBrandBundle = document.getElementById("bundle_brand");
gProfileManagerBundle = document.getElementById("bundle_profileManager");
gBrandBundle = document.getElementById("bundle_brand");
document.documentElement.centerWindowOnScreen();
document.documentElement.getButton('accept').focus();
document.documentElement.centerWindowOnScreen();
var profilesElement = document.getElementById("profiles");
var profileList = gProfileService.profiles;
while (profileList.hasMoreElements()) {
var profile = profileList.getNext().QueryInterface(I.nsIToolkitProfile);
var listitem = profilesElement.appendItem(profile.name, "");
var tooltiptext =
gProfileManagerBundle.getFormattedString("profileTooltip", [profile.name, profile.rootDir.path]);
listitem.setAttribute("tooltiptext", tooltiptext);
listitem.setAttribute("class", "listitem-iconic");
listitem.profile = profile;
try {
if (profile === gProfileService.selectedProfile) {
setTimeout(function(a) {
profilesElement.ensureElementIsVisible(a);
profilesElement.selectItem(a);
}, 0, listitem);
}
}
catch(e) { }
}
var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
autoSelectLastProfile.checked = gProfileService.startWithLastProfile;
profilesElement.focus();
}
catch(e) {
window.close();
throw (e);
}
}
function acceptDialog()
{
var appName = gBrandBundle.getString("brandShortName");
var selectedProfile = gProfileService.selectedProfile;
var profilesElement = document.getElementById("profiles");
var selectedProfile = profilesElement.selectedItem;
if (!selectedProfile) {
var pleaseSelectTitle = gProfileManagerBundle.getString("pleaseSelectTitle");
var pleaseSelect =
@ -46,10 +82,10 @@ function acceptDialog()
var profileLock;
try {
profileLock = selectedProfile.lock({ value: null });
profileLock = selectedProfile.profile.lock({ value: null });
}
catch (e) {
if (!selectedProfile.rootDir.exists()) {
if (!selectedProfile.profile.rootDir.exists()) {
var missingTitle = gProfileManagerBundle.getString("profileMissingTitle");
var missing =
gProfileManagerBundle.getFormattedString("profileMissing", [appName]);
@ -59,21 +95,175 @@ function acceptDialog()
var lockedTitle = gProfileManagerBundle.getString("profileLockedTitle");
var locked =
gProfileManagerBundle.getFormattedString("profileLocked2", [appName, selectedProfile.name, appName]);
gProfileManagerBundle.getFormattedString("profileLocked2", [appName, selectedProfile.profile.name, appName]);
Services.prompt.alert(window, lockedTitle, locked);
return false;
}
gDialogParams.objects.insertElementAt(profileLock.nsIProfileLock, 0, false);
gProfileService.selectedProfile = selectedProfile.profile;
gProfileService.defaultProfile = selectedProfile.profile;
updateStartupPrefs();
gDialogParams.SetInt(0, 1);
gDialogParams.SetString(0, selectedProfile.name);
gDialogParams.SetString(0, selectedProfile.profile.name);
return true;
}
function exitDialog()
{
updateStartupPrefs();
return true;
}
function updateStartupPrefs()
{
var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
gProfileService.startWithLastProfile = autoSelectLastProfile.checked;
/* Bug 257777 */
gProfileService.startOffline = document.getElementById("offlineState").checked;
}
// handle key event on listboxes
function onProfilesKey(aEvent)
{
switch( aEvent.keyCode )
{
case KeyEvent.DOM_VK_BACK_SPACE:
if (AppConstants.platform != "macosx")
break;
case KeyEvent.DOM_VK_DELETE:
ConfirmDelete();
break;
case KeyEvent.DOM_VK_F2:
RenameProfile();
break;
}
}
function onProfilesDblClick(aEvent)
{
if(aEvent.target.localName == "listitem")
document.documentElement.acceptDialog();
}
// invoke the createProfile Wizard
function CreateProfileWizard()
{
window.openDialog('chrome://mozapps/content/profile/createProfileWizard.xul',
'', 'centerscreen,chrome,modal,titlebar', gProfileService);
}
/**
* Called from createProfileWizard to update the display.
*/
function CreateProfile(aProfile)
{
var profilesElement = document.getElementById("profiles");
var listitem = profilesElement.appendItem(aProfile.name, "");
var tooltiptext =
gProfileManagerBundle.getFormattedString("profileTooltip", [aProfile.name, aProfile.rootDir.path]);
listitem.setAttribute("tooltiptext", tooltiptext);
listitem.setAttribute("class", "listitem-iconic");
listitem.profile = aProfile;
profilesElement.ensureElementIsVisible(listitem);
profilesElement.selectItem(listitem);
}
// rename the selected profile
function RenameProfile()
{
var profilesElement = document.getElementById("profiles");
var selectedItem = profilesElement.selectedItem;
if (!selectedItem) {
return false;
}
var selectedProfile = selectedItem.profile;
var oldName = selectedProfile.name;
var newName = {value: oldName};
var dialogTitle = gProfileManagerBundle.getString("renameProfileTitle");
var msg =
gProfileManagerBundle.getFormattedString("renameProfilePrompt", [oldName]);
if (Services.prompt.prompt(window, dialogTitle, msg, newName, null, {value:0})) {
newName = newName.value;
// User hasn't changed the profile name. Treat as if cancel was pressed.
if (newName == oldName)
return false;
try {
selectedProfile.name = newName;
}
catch (e) {
var alTitle = gProfileManagerBundle.getString("profileNameInvalidTitle");
var alMsg = gProfileManagerBundle.getFormattedString("profileNameInvalid", [newName]);
Services.prompt.alert(window, alTitle, alMsg);
return false;
}
selectedItem.label = newName;
var tiptext = gProfileManagerBundle.
getFormattedString("profileTooltip",
[newName, selectedProfile.rootDir.path]);
selectedItem.setAttribute("tooltiptext", tiptext);
return true;
}
return false;
}
function ConfirmDelete()
{
var deleteButton = document.getElementById("delbutton");
var profileList = document.getElementById( "profiles" );
var selectedItem = profileList.selectedItem;
if (!selectedItem) {
return false;
}
var selectedProfile = selectedItem.profile;
var deleteFiles = false;
if (selectedProfile.rootDir.exists()) {
var dialogTitle = gProfileManagerBundle.getString("deleteTitle");
var dialogText =
gProfileManagerBundle.getFormattedString("deleteProfileConfirm",
[selectedProfile.rootDir.path]);
var buttonPressed = Services.prompt.confirmEx(window, dialogTitle, dialogText,
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
(Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) +
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2),
gProfileManagerBundle.getString("dontDeleteFiles"),
null,
gProfileManagerBundle.getString("deleteFiles"),
null, {value:0});
if (buttonPressed == 1)
return false;
if (buttonPressed == 2)
deleteFiles = true;
}
selectedProfile.remove(deleteFiles);
profileList.removeChild(selectedItem);
if (profileList.firstChild != undefined) {
profileList.selectItem(profileList.firstChild);
}
return true;
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!--
@ -6,7 +6,7 @@
- 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/. -->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/profile/profileSelection.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
@ -17,12 +17,12 @@
<dialog
id="profileWindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="non-resizable"
title="&windowtitle.label;"
orient="vertical"
orient="vertical"
buttons="accept,cancel"
style="width: 60em; height: 40em;"
style="width: 30em;"
onload="startup();"
ondialogaccept="return acceptDialog()"
ondialogcancel="return exitDialog()"
@ -36,6 +36,35 @@
<script type="application/javascript" src="chrome://mozapps/content/profile/profileSelection.js"/>
<browser id="browser" src="about:profiles?manage" flex="1" />
<description class="label">&pmDescription.label;</description>
<separator class="thin"/>
<hbox class="profile-box indent" flex="1">
<vbox id="managebuttons">
<button id="newbutton" label="&newButton.label;"
accesskey="&newButton.accesskey;" oncommand="CreateProfileWizard();"/>
<button id="renbutton" label="&renameButton.label;"
accesskey="&renameButton.accesskey;" oncommand="RenameProfile();"/>
<button id="delbutton" label="&deleteButton.label;"
accesskey="&deleteButton.accesskey;" oncommand="ConfirmDelete();"/>
</vbox>
<separator flex="1"/>
<vbox flex="1">
<listbox id="profiles" rows="5" seltype="single"
ondblclick="onProfilesDblClick(event)"
onkeypress="onProfilesKey(event);">
</listbox>
<!-- Bug 257777 -->
<checkbox id="offlineState" label="&offlineState.label;" accesskey="&offlineState.accesskey;"/>
<checkbox id="autoSelectLastProfile" label="&useSelected.label;"
accesskey="&useSelected.accesskey;"/>
</vbox>
</hbox>
</dialog>

View File

@ -48,6 +48,7 @@ toolkit.jar:
skin/classic/mozapps/plugins/pluginGeneric-16.png (plugins/pluginGeneric-16.png)
skin/classic/mozapps/plugins/pluginHelp-16.png (plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileicon.png (profile/profileicon.png)
skin/classic/mozapps/profile/profileSelection.css (profile/profileSelection.css)
skin/classic/mozapps/profile/profileicon-selected.png (profile/profileicon-selected.png)
skin/classic/mozapps/update/buttons.png (update/buttons.png)
* skin/classic/mozapps/update/updates.css (update/updates.css)

View File

@ -0,0 +1,29 @@
/* 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/. */
@import url("chrome://global/skin/global.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#profiles > listitem {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#profiles:focus > listitem[selected="true"] {
list-style-image: url("chrome://mozapps/skin/profile/profileicon-selected.png");
}
#profiles > listitem > listcell > image {
width: 16px;
height: 16px;
}
box#managebuttons > button {
min-width: 8em;
}
#managebuttons {
padding-top: 1em;
}

View File

@ -155,6 +155,7 @@
#endif
skin/classic/mozapps/plugins/pluginBlocked-64.png (../../windows/mozapps/plugins/pluginBlocked-64.png)
skin/classic/mozapps/plugins/pluginHelp-16.png (../../windows/mozapps/plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileSelection.css (../../windows/mozapps/profile/profileSelection.css)
skin/classic/mozapps/update/downloadButtons.png (../../windows/mozapps/update/downloadButtons.png)
* skin/classic/mozapps/xpinstall/xpinstallConfirm.css (../../windows/mozapps/extensions/xpinstallConfirm.css)

View File

@ -0,0 +1,25 @@
/* 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/. */
@import url("chrome://global/skin/global.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#profiles > listitem {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#profiles > listitem > listcell > image {
width: 16px;
height: 16px;
}
box#managebuttons > button {
min-width: 8em;
}
#managebuttons {
padding-top: 1em;
}