Skip to content

Commit

Permalink
Add copy dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Sep 20, 2022
1 parent 42c20c5 commit abd924e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
@click="handlers.setCurrentHistory(history)">
Switch to this history
</b-button>
<b-button v-else size="sm" variant="outline-info" title="Import this history" @click="onImport">
<b-button
v-else
size="sm"
variant="outline-info"
title="Import this history"
v-b-modal:copy-history-modal>
Import this history
</b-button>
</div>
Expand All @@ -28,21 +33,23 @@
:history="history"
:show-controls="false"
@view-collection="onViewCollection" />
<CopyModal id="copy-history-modal" :history="history" />
</div>
<b-alert v-else class="m-2" variant="info" show>
<LoadingSpan message="Loading Histories" />
<LoadingSpan message="Loading History" />
</b-alert>
</UserHistories>
</CurrentUser>
</template>

<script>
import { mapGetters } from "vuex";
import CollectionPanel from "components/History/CurrentCollection/CollectionPanel";
import CurrentUser from "components/providers/CurrentUser";
import HistoryPanel from "components/History/CurrentHistory/HistoryPanel";
import LoadingSpan from "components/LoadingSpan";
import UserHistories from "components/providers/UserHistories";
import LoadingSpan from "components/LoadingSpan";
import CollectionPanel from "./CurrentCollection/CollectionPanel";
import HistoryPanel from "./CurrentHistory/HistoryPanel";
import CopyModal from "./Modals/CopyModal";
export default {
components: {
Expand All @@ -51,6 +58,7 @@ export default {
CollectionPanel,
CurrentUser,
UserHistories,
CopyModal,
},
props: {
id: {
Expand All @@ -73,7 +81,6 @@ export default {
},
},
methods: {
onImport() {},
onViewCollection(collection) {
this.selectedCollections = [...this.selectedCollections, collection];
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Grid from "components/Grid/Grid";
import GridShared from "components/Grid/GridShared";
import GridHistory from "components/Grid/GridHistory";
import HistoryImport from "components/HistoryImport";
import HistoryView from "components/HistoryView";
import HistoryView from "components/History/HistoryView";
import HistoryMultipleView from "components/History/Multiple/MultipleView";
import InteractiveTools from "components/InteractiveTools/InteractiveTools";
import InvocationReport from "components/Workflow/InvocationReport";
Expand Down
87 changes: 8 additions & 79 deletions templates/webapps/galaxy/history/display.mako
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<%inherit file="/display_base.mako"/>

## Set vars so that there's no need to change the code below.
<%
history = published_item
datasets = published_item_data
%>

<%def name="javascripts()">
${parent.javascripts()}
</%def>
Expand All @@ -15,83 +9,18 @@
</%def>

<%def name="render_item_links( history )">
<%
encoded_history_id = history_dict[ 'id' ]
switch_url = h.url_for( controller='history', action='switch_to_history', hist_id=encoded_history_id )
%>
%if not user_is_owner:
<a href="javascript:void(0)" class="history-copy-link btn btn-secondary float-right" title="Import this history">
<span class="fa fa-plus"></span>
Import
</a>
%else:
<a href="${switch_url}" class="btn btn-secondary float-right" title="Switch to this history">
<span class="fa fa-exchange"></span>
Switch
</a>
%endif
</%def>

<%def name="render_item_header( item )">
</%def>

<%def name="render_item( history, datasets )">
<div id="history-${ history_dict[ 'id' ] }" class="history-panel"></div>
<script type="text/javascript">
config.addInitialization(function(galaxy, config) {
console.log("display.mako render_item");
var historyJSON = ${h.dumps(history_dict)};
// Why are we adding a css prop and a class, can't the
// prop be part of the class?
$('.page-body')
.css('height', '100%')
.addClass('flex-vertical-container');
var HistoryContentsWithAnnotations = window.bundleEntries.HistoryContents.extend({
_buildFetchData : function( options ){
console.log( '_buildFetchData:' );
options = options || {};
if( !options.keys && !options.view ){
options.view = 'summary';
options.keys = 'annotation,tags';
}
return window.bundleEntries.HistoryContents.prototype._buildFetchData.call( this, options );
}
});
var HistoryWithAnnotations = window.bundleEntries.History.extend({
contentsClass : HistoryContentsWithAnnotations
});
var historyModel = new HistoryWithAnnotations( historyJSON, null, {
order : 'hid-asc',
});
$('.history-copy-link').click( function( ev ){
window.bundleEntries.HistoryCopyDialog( historyModel, { useImport: true, allowAll: false })
.done( function(){
var mainWindow = ( window && ( window !== window.parent ) )? window.top : window;
mainWindow.location.href = Galaxy.root;
});
});
window.historyView = new window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView({
el : $( "#history-" + historyJSON.id ),
className : window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView.prototype.className + ' wide',
model : historyModel,
show_deleted : false,
show_hidden : false,
<%def name="render_item( item, item_data )">
<% history_id = trans.security.encode_id(item.id) %>
<div id="history-${ history_id }"></div>
<script type="text/javascript">
config.addInitialization(function(galaxy, config) {
console.log("display.mako render_item");
window.bundleEntries.mountHistory("#history-${ history_id }", { id: "${ history_id }" });
});
historyView.trigger( 'loading' );
historyModel.fetchContents({ silent: true })
.fail( function(){ alert( 'Galaxy history failed to load' ); })
.done( function(){
historyView.trigger( 'loading-done' );
historyView.render();
});
});
</script>
</script>
</%def>

0 comments on commit abd924e

Please sign in to comment.