mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
History, options menu: prevent AMD race conditions with Galaxy object by rendering options menu vars server-side
This commit is contained in:
@@ -120,8 +120,7 @@ var menu = [
|
||||
}
|
||||
];
|
||||
|
||||
function buildMenu( isAnon, purgeAllowed ){
|
||||
var urlRoot = Galaxy.options.root;
|
||||
function buildMenu( isAnon, purgeAllowed, urlRoot ){
|
||||
return _.clone( menu ).filter( function( menuOption ){
|
||||
if( isAnon && !menuOption.anon ){
|
||||
return false;
|
||||
@@ -150,11 +149,13 @@ var create = function( $button, options ){
|
||||
options = options || {};
|
||||
var isAnon = options.anonymous === undefined? true : options.anonymous,
|
||||
purgeAllowed = options.purgeAllowed || false,
|
||||
menu = buildMenu( isAnon, purgeAllowed );
|
||||
root = options.root || ( ( Galaxy && Galaxy.options )? Galaxy.options.root: '/' ),
|
||||
menu = buildMenu( isAnon, purgeAllowed, root );
|
||||
//console.debug( 'menu:', menu );
|
||||
return new PopupMenu( $button, menu );
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
return create;
|
||||
});
|
||||
|
||||
@@ -120,8 +120,7 @@ var menu = [
|
||||
}
|
||||
];
|
||||
|
||||
function buildMenu( isAnon, purgeAllowed ){
|
||||
var urlRoot = Galaxy.options.root;
|
||||
function buildMenu( isAnon, purgeAllowed, urlRoot ){
|
||||
return _.clone( menu ).filter( function( menuOption ){
|
||||
if( isAnon && !menuOption.anon ){
|
||||
return false;
|
||||
@@ -150,11 +149,13 @@ var create = function( $button, options ){
|
||||
options = options || {};
|
||||
var isAnon = options.anonymous === undefined? true : options.anonymous,
|
||||
purgeAllowed = options.purgeAllowed || false,
|
||||
menu = buildMenu( isAnon, purgeAllowed );
|
||||
root = options.root || ( ( Galaxy && Galaxy.options )? Galaxy.options.root: '/' ),
|
||||
menu = buildMenu( isAnon, purgeAllowed, root );
|
||||
//console.debug( 'menu:', menu );
|
||||
return new PopupMenu( $button, menu );
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
return create;
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
define(["mvc/base-mvc","utils/localization"],function(a,d){var e=[{html:d("History Lists"),header:true},{html:d("Saved Histories"),href:"history/list"},{html:d("Histories Shared with Me"),href:"history/list_shared"},{html:d("Current History"),header:true,anon:true},{html:d("Create New"),func:function(){if(Galaxy&&Galaxy.currHistoryPanel){Galaxy.currHistoryPanel.createNewHistory()}}},{html:d("Copy History"),href:"history/copy"},{html:d("Copy Datasets"),href:"dataset/copy_datasets"},{html:d("Share or Publish"),href:"history/sharing"},{html:d("Extract Workflow"),href:"workflow/build_from_current_history"},{html:d("Dataset Security"),href:"root/history_set_default_permissions"},{html:d("Resume Paused Jobs"),href:"history/resume_paused_jobs?current=True",anon:true},{html:d("Collapse Expanded Datasets"),func:function(){if(Galaxy&&Galaxy.currHistoryPanel){Galaxy.currHistoryPanel.collapseAll()}}},{html:d("Unhide Hidden Datasets"),confirm:d("Really unhide all hidden datasets?"),href:"history/unhide_datasets?current=True",anon:true},{html:d("Delete Hidden Datasets"),confirm:d("Really delete all hidden datasets?"),href:"history/delete_hidden_datasets",anon:true},{html:d("Purge Deleted Datasets"),confirm:d("Really delete all deleted datasets permanently? This cannot be undone."),href:"history/purge_deleted_datasets",purge:true,anon:true},{html:d("Show Structure"),href:"history/display_structured",anon:true},{html:d("Export Citations"),href:"history/citations",anon:true},{html:d("Export to File"),href:"history/export_archive?preview=True",anon:true},{html:d("Delete"),confirm:d("Really delete the current history?"),href:"history/delete_current"},{html:d("Delete Permanently"),confirm:d("Really delete the current history permanently? This cannot be undone."),href:"history/delete_current?purge=True",purge:true,anon:true},{html:d("Other Actions"),header:true},{html:d("Import from File"),href:"history/import_archive"}];function c(h,g){var f=Galaxy.options.root;return _.clone(e).filter(function(i){if(h&&!i.anon){return false}if(!g&&i.purge){return false}if(i.href){i.href=f+i.href;i.target="galaxy_main"}if(i.confirm){i.func=function(){if(confirm(i.confirm)){galaxy_main.location=i.href}}}return true})}var b=function(h,f){f=f||{};var i=f.anonymous===undefined?true:f.anonymous,g=f.purgeAllowed||false,j=c(i,g);return new PopupMenu(h,j)};return b});
|
||||
define(["mvc/base-mvc","utils/localization"],function(a,d){var e=[{html:d("History Lists"),header:true},{html:d("Saved Histories"),href:"history/list"},{html:d("Histories Shared with Me"),href:"history/list_shared"},{html:d("Current History"),header:true,anon:true},{html:d("Create New"),func:function(){if(Galaxy&&Galaxy.currHistoryPanel){Galaxy.currHistoryPanel.createNewHistory()}}},{html:d("Copy History"),href:"history/copy"},{html:d("Copy Datasets"),href:"dataset/copy_datasets"},{html:d("Share or Publish"),href:"history/sharing"},{html:d("Extract Workflow"),href:"workflow/build_from_current_history"},{html:d("Dataset Security"),href:"root/history_set_default_permissions"},{html:d("Resume Paused Jobs"),href:"history/resume_paused_jobs?current=True",anon:true},{html:d("Collapse Expanded Datasets"),func:function(){if(Galaxy&&Galaxy.currHistoryPanel){Galaxy.currHistoryPanel.collapseAll()}}},{html:d("Unhide Hidden Datasets"),confirm:d("Really unhide all hidden datasets?"),href:"history/unhide_datasets?current=True",anon:true},{html:d("Delete Hidden Datasets"),confirm:d("Really delete all hidden datasets?"),href:"history/delete_hidden_datasets",anon:true},{html:d("Purge Deleted Datasets"),confirm:d("Really delete all deleted datasets permanently? This cannot be undone."),href:"history/purge_deleted_datasets",purge:true,anon:true},{html:d("Show Structure"),href:"history/display_structured",anon:true},{html:d("Export Citations"),href:"history/citations",anon:true},{html:d("Export to File"),href:"history/export_archive?preview=True",anon:true},{html:d("Delete"),confirm:d("Really delete the current history?"),href:"history/delete_current"},{html:d("Delete Permanently"),confirm:d("Really delete the current history permanently? This cannot be undone."),href:"history/delete_current?purge=True",purge:true,anon:true},{html:d("Other Actions"),header:true},{html:d("Import from File"),href:"history/import_archive"}];function c(h,g,f){return _.clone(e).filter(function(i){if(h&&!i.anon){return false}if(!g&&i.purge){return false}if(i.href){i.href=f+i.href;i.target="galaxy_main"}if(i.confirm){i.func=function(){if(confirm(i.confirm)){galaxy_main.location=i.href}}}return true})}var b=function(i,g){g=g||{};var j=g.anonymous===undefined?true:g.anonymous,h=g.purgeAllowed||false,f=g.root||((Galaxy&&Galaxy.options)?Galaxy.options.root:"/"),k=c(j,h,f);return new PopupMenu(i,k)};return b});
|
||||
@@ -126,10 +126,12 @@
|
||||
});
|
||||
require([ 'mvc/history/options-menu' ], function( optionsMenu ){
|
||||
$(function(){
|
||||
//##TODO: Galaxy is not reliably available here since index doesn't use app
|
||||
var popupmenu = optionsMenu( $( "#history-options-button" ), {
|
||||
anonymous : Galaxy.currUser.isAnonymous(),
|
||||
purgeAllowed : Galaxy.config.allow_user_dataset_purge
|
||||
});
|
||||
anonymous : ${ 'true' if not trans.user else 'false' },
|
||||
purgeAllowed : ${ 'true' if trans.app.config.allow_user_dataset_purge else 'false' },
|
||||
root : '${ h.url_for( "/" ) }'
|
||||
});
|
||||
Galaxy.historyOptionsMenu = popupmenu;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user