Add collections pane context-menu option to remove archived libraries

This commit is contained in:
Dan Stillman 2017-02-24 02:29:11 -05:00
parent 9ac458e05c
commit 2fe756c1c9
3 changed files with 47 additions and 9 deletions

View file

@ -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

View file

@ -275,6 +275,7 @@
<menuitem class="zotero-menuitem-export" label="&zotero.toolbar.export.label;"/>
<menuitem class="zotero-menuitem-create-report"/>
<menuitem class="zotero-menuitem-delete-from-lib" label="&zotero.toolbar.emptyTrash.label;"/>
<menuitem class="zotero-menuitem-removeLibrary"/>
</menupopup>
<menupopup id="zotero-itemmenu">
<!-- Keep order in sync with buildItemContextMenu -->

View file

@ -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…