mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Streamline the process of importing library datasets into histories:
1) Allow imports from the admin view instead of just the Data Libraries view. 2) Add a new 1-click option when acting on multiple selected library datasets to import them into the current history. 3) when importing selected library datasets into selected histories, make the current history selected by default. 4) Add the ability to import the current library dataset into a selected history when viewing the library dataset info page.
This commit is contained in:
@@ -858,7 +858,7 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
message += "Click the Go button at the bottom of this page to edit the permissions on these datasets if necessary."
|
||||
default_action = 'manage_permissions'
|
||||
else:
|
||||
default_action = 'import_to_histories'
|
||||
default_action = 'import_to_current_history'
|
||||
trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='browse_library',
|
||||
cntrller=cntrller,
|
||||
@@ -1238,7 +1238,7 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
message += "Click the Go button at the bottom of this page to edit the permissions on these datasets if necessary."
|
||||
default_action = 'manage_permissions'
|
||||
else:
|
||||
default_action = 'import_to_histories'
|
||||
default_action = 'import_to_current_history'
|
||||
return trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='browse_library',
|
||||
cntrller=cntrller,
|
||||
@@ -1547,6 +1547,7 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
error = False
|
||||
is_admin = trans.user_is_admin() and cntrller == 'library_admin'
|
||||
current_user_roles = trans.get_current_user_roles()
|
||||
current_history = trans.get_history()
|
||||
if not ldda_ids:
|
||||
error = True
|
||||
message = 'You must select at least one dataset.'
|
||||
@@ -1554,16 +1555,27 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
error = True
|
||||
message = 'You must select an action to perform on the selected datasets.'
|
||||
else:
|
||||
if action == 'import_to_histories':
|
||||
if action in [ 'import_to_current_history', 'import_to_histories' ]:
|
||||
new_kwd = {}
|
||||
if action == 'import_to_current_history':
|
||||
encoded_current_history_id = trans.security.encode_id( current_history.id )
|
||||
selected_history_id = encoded_current_history_id
|
||||
new_kwd[ 'do_action' ] = action
|
||||
new_kwd[ 'target_history_ids' ] = encoded_current_history_id
|
||||
new_kwd[ 'import_datasets_to_histories_button' ] = 'Import library datasets'
|
||||
else:
|
||||
selected_history_id = ''
|
||||
return trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='import_datasets_to_histories',
|
||||
cntrller=cntrller,
|
||||
library_id=library_id,
|
||||
selected_history_id=selected_history_id,
|
||||
ldda_ids=ldda_ids,
|
||||
use_panels=use_panels,
|
||||
show_deleted=show_deleted,
|
||||
message=message,
|
||||
status=status ) )
|
||||
status=status,
|
||||
**new_kwd ) )
|
||||
if action == 'move':
|
||||
if library_id in [ 'none', 'None', None ]:
|
||||
source_library_id = ''
|
||||
@@ -1808,8 +1820,10 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
status = params.get( 'status', 'done' )
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
use_panels = util.string_as_bool( params.get( 'use_panels', False ) )
|
||||
action = params.get( 'do_action', None )
|
||||
user = trans.get_user()
|
||||
current_history = trans.get_history()
|
||||
selected_history_id = params.get( 'selected_history_id', trans.security.encode_id( current_history.id ) )
|
||||
if library_id:
|
||||
library = trans.sa_session.query( trans.model.Library ).get( trans.security.decode_id( library_id ) )
|
||||
else:
|
||||
@@ -1886,11 +1900,20 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
target_histories = [ current_history ]
|
||||
if user:
|
||||
target_histories = user.active_histories
|
||||
if action == 'import_to_current_history' and library_id:
|
||||
# To streamline this as much as possible, go back to browsing the library.
|
||||
return trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='browse_library',
|
||||
cntrller=cntrller,
|
||||
id=library_id,
|
||||
message=util.sanitize_text( message ),
|
||||
status=status ) )
|
||||
return trans.fill_template( "/library/common/import_datasets_to_histories.mako",
|
||||
cntrller=cntrller,
|
||||
library=library,
|
||||
current_history=trans.get_history(),
|
||||
current_history=current_history,
|
||||
ldda_ids=ldda_ids,
|
||||
selected_history_id=selected_history_id,
|
||||
target_history_ids=target_history_ids,
|
||||
source_lddas=source_lddas,
|
||||
target_histories=target_histories,
|
||||
|
||||
@@ -403,11 +403,12 @@
|
||||
For selected datasets:
|
||||
<select name="do_action" id="action_on_selected_items">
|
||||
%if can_import_to_histories:
|
||||
%if not is_admin and default_action == 'import_to_histories':
|
||||
<option value="import_to_histories" selected>Import to histories</option>
|
||||
%if default_action == 'import_to_current_history':
|
||||
<option value="import_to_current_history" selected>Import to current history</option>
|
||||
%else:
|
||||
<option value="import_to_histories">Import to histories</option>
|
||||
<option value="import_to_current_history">Import to current history</option>
|
||||
%endif
|
||||
<option value="import_to_histories">Import to histories</option>
|
||||
%endif
|
||||
%if can_manage_permissions:
|
||||
%if not is_admin and default_action == 'manage_permissions':
|
||||
|
||||
@@ -50,16 +50,19 @@
|
||||
<div class="toolFormBody">
|
||||
<div class="form-row" id="single-destination">
|
||||
<select id="single-dest-select" name="target_history_ids">
|
||||
<option value=""></option>
|
||||
%for i, target_history in enumerate( target_histories ):
|
||||
<%
|
||||
encoded_id = trans.security.encode_id( target_history.id )
|
||||
if encoded_id == selected_history_id:
|
||||
selected_text = " selected"
|
||||
else:
|
||||
selected_text = ""
|
||||
if target_history == current_history:
|
||||
current_history_text = " (current history)"
|
||||
else:
|
||||
current_history_text = ""
|
||||
%>
|
||||
<option value="${encoded_id}">${i + 1}: ${h.truncate( target_history.name, 30 )}${current_history_text}</option>
|
||||
<option value="${encoded_id}"${selected_text}>${i + 1}: ${h.truncate( target_history.name, 30 )}${current_history_text}</option>
|
||||
%endfor
|
||||
</select>
|
||||
<br/><br/>
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
%if current_version and can_modify:
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), replace_id=trans.security.encode_id( ldda.library_dataset.id ) )}">Upload a new version of this dataset</a>
|
||||
%endif
|
||||
%if cntrller=='library' and ldda.has_data():
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Select histories to import this dataset</a>
|
||||
%if ldda.has_data():
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into selected histories</a>
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='download_dataset_from_folder', cntrller=cntrller, id=trans.security.encode_id( ldda.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Download this dataset</a>
|
||||
%endif
|
||||
%if show_associated_hdas_and_lddas:
|
||||
|
||||
Reference in New Issue
Block a user