Bug 427633 - Disable creating a New Folder in the bookmarks dialogs if insertionPoint is invalid, r=dietrich
authorMarco Bonardo <mak77@bonardo.net>
Tue, 13 Jan 2009 11:48:26 +0100
changeset 23592 23273773e4523b8d3e93f1af68a3b5d92b2cddec
parent 23591 c774155fb74701a1486656b6bfb9b5b8f4c3898a
child 23593 6ddb1b2244aa314c5cbdd8a26190e93c64030594
push id4625
push usermak77@bonardo.net
push dateTue, 13 Jan 2009 11:44:36 +0000
treeherdermozilla-central@5b18412c4c4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs427633
milestone1.9.2a1pre
Bug 427633 - Disable creating a New Folder in the bookmarks dialogs if insertionPoint is invalid, r=dietrich
browser/components/places/content/editBookmarkOverlay.js
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -850,16 +850,21 @@ var gEditItemOverlay = {
       if (!selectedNode ||
           PlacesUtils.getConcreteItemId(selectedNode) != container)
         this._folderTree.selectItems([container]);
     }
   },
 
   onFolderTreeSelect: function EIO_onFolderTreeSelect() {
     var selectedNode = this._folderTree.selectedNode;
+
+    // Disable the "New Folder" button if we cannot create a new folder
+    this._element("newFolderButton")
+        .disabled = !this._folderTree.insertionPoint || !selectedNode;
+
     if (!selectedNode)
       return;
 
     var folderId = PlacesUtils.getConcreteItemId(selectedNode);
     if (this._getFolderIdFromMenuList() == folderId)
       return;
 
     var folderItem = this._getFolderMenuItem(folderId);
@@ -966,21 +971,20 @@ var gEditItemOverlay = {
     }
     return tags;
   },
 
   newFolder: function EIO_newFolder() {
     var ip = this._folderTree.insertionPoint;
 
     // default to the bookmarks menu folder
-    if (!ip ||
-        ip.itemId == PlacesUIUtils.allBookmarksFolderId ||
-        ip.itemId == PlacesUIUtils.unfiledBookmarksFolderId) {
-      ip.itemId = PlacesUtils.bookmarksMenuFolderId;
-      ip.index = -1;
+    if (!ip || ip.itemId == PlacesUIUtils.allBookmarksFolderId) {
+        ip = new InsertionPoint(PlacesUtils.bookmarksMenuFolderId,
+                                PlacesUtils.bookmarks.DEFAULT_INDEX,
+                                Ci.nsITreeView.DROP_ON);
     }
 
     // XXXmano: add a separate "New Folder" string at some point...
     var defaultLabel = this._element("newFolderButton").label;
     var txn = PlacesUIUtils.ptm.createFolder(defaultLabel, ip.itemId, ip.index);
     PlacesUIUtils.ptm.doTransaction(txn);
     this._folderTree.focus();
     this._folderTree.selectItems([this._lastNewItem]);