diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index e728dbcefba..aac19631bb5 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -497,6 +497,21 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI # return trans.fill_template( "history/display_structured.mako", items=items ) + @web.expose + def delete_hidden_datasets( self, trans ): + """ + This method deletes all hidden datasets in the current history. + """ + count = 0 + for hda in trans.history.datasets: + if not hda.visible and not hda.deleted and not hda.purged: + hda.mark_deleted() + count += 1 + trans.sa_session.add( hda ) + trans.log_event( "HDA id %s has been deleted" % hda.id ) + trans.sa_session.flush() + return trans.show_ok_message( "%d hidden datasets have been deleted" % count, refresh_frames=['history'] ) + @web.expose def purge_deleted_datasets( self, trans ): count = 0 diff --git a/templates/webapps/galaxy/root/index.mako b/templates/webapps/galaxy/root/index.mako index 029d9bc0726..43c4bda7032 100644 --- a/templates/webapps/galaxy/root/index.mako +++ b/templates/webapps/galaxy/root/index.mako @@ -45,6 +45,11 @@ galaxy_main.location = "${h.url_for( controller='history', action='unhide_datasets', current=True )}"; } }, + "${_("Delete Hidden Datasets")}": function() { + if ( confirm( "Really delete all hidden datasets?" ) ) { + galaxy_main.location = "${h.url_for( controller='history', action='delete_hidden_datasets')}"; + } + }, "${_("Purge Deleted Datasets")}": function() { if ( confirm( "Really delete all deleted datasets permanently? This cannot be undone." ) ) { galaxy_main.location = "${h.url_for( controller='history', action='purge_deleted_datasets' )}";