From 2fe756c1c9d29202e995191ec9fcdcd10d70ead8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 24 Feb 2017 02:29:11 -0500 Subject: [PATCH] Add collections pane context-menu option to remove archived libraries --- chrome/content/zotero/zoteroPane.js | 51 ++++++++++++++++---- chrome/content/zotero/zoteroPane.xul | 1 + chrome/locale/en-US/zotero/zotero.properties | 4 ++ 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 599af3b0be..23be338ae0 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2425,7 +2425,29 @@ var ZoteroPane = new function() { id: "emptyTrash", onclick: () => this.emptyTrash() - } + }, + { + id: "removeLibrary", + label: Zotero.getString('pane.collections.menu.remove.library'), + onclick: () => { + let library = Zotero.Libraries.get(libraryID); + let ps = Services.prompt; + let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); + let index = ps.confirmEx( + null, + Zotero.getString('pane.collections.removeLibrary'), + Zotero.getString('pane.collections.removeLibrary.text', library.name), + buttonFlags, + Zotero.getString('general.remove'), + null, + null, null, {} + ); + if (index == 0) { + library.eraseTx(); + } + } + }, ]; @@ -2554,12 +2576,16 @@ var ZoteroPane = new function() } // Library else { - show = [ - 'sync', - 'sep1', - 'newCollection', - 'newSavedSearch', - ]; + let library = Zotero.Libraries.get(libraryID); + show = []; + if (!library.archived) { + show.push( + 'sync', + 'sep1', + 'newCollection', + 'newSavedSearch' + ); + } // Only show "Show Duplicates" and "Show Unfiled Items" if rows are hidden let duplicates = Zotero.Utilities.Internal.getVirtualCollectionStateForLibrary( libraryID, 'duplicates' @@ -2568,7 +2594,9 @@ var ZoteroPane = new function() libraryID, 'unfiled' ); if (!duplicates || !unfiled) { - show.push('sep2'); + if (!library.archived) { + show.push('sep2'); + } if (!duplicates) { show.push('showDuplicates'); } @@ -2576,10 +2604,15 @@ var ZoteroPane = new function() show.push('showUnfiled'); } } + if (!library.archived) { + show.push('sep3'); + } show.push( - 'sep3', 'exportFile' ); + if (library.archived) { + show.push('removeLibrary'); + } } // Disable some actions if user doesn't have write access diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index a30f1a1d57..2bfd461c94 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -275,6 +275,7 @@ + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index dc77cd09ae..896dc86a50 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -40,6 +40,7 @@ general.character.singular = character general.character.plural = characters general.create = Create general.delete = Delete +general.remove = Remove general.moreInformation = More Information general.seeForMoreInformation = See %S for more information. general.open = Open %S @@ -204,10 +205,13 @@ pane.collections.trash = Trash pane.collections.untitled = Untitled pane.collections.unfiled = Unfiled Items pane.collections.duplicate = Duplicate Items +pane.collections.removeLibrary = Remove Library +pane.collections.removeLibrary.text = Are you sure you want to permanently remove “%S” from this computer? pane.collections.menu.rename.collection = Rename Collection… pane.collections.menu.edit.savedSearch = Edit Saved Search… pane.collections.menu.edit.feed = Edit Feed… +pane.collections.menu.remove.library = Remove Library… pane.collections.menu.delete.collection = Delete Collection… pane.collections.menu.delete.collectionAndItems = Delete Collection and Items… pane.collections.menu.delete.savedSearch = Delete Saved Search…