Skip to content

Commit

Permalink
Merge pull request #203 from EBI-Metagenomics/develop
Browse files Browse the repository at this point in the history
Legacy assembly redirection
  • Loading branch information
mberacochea authored Jan 27, 2022
2 parents e5886fe + 18948da commit fe6bbd4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions ci/emg_sql_fixtures/emg_LEGACY_ASSEMBLIES.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO `LEGACY_ASSEMBLY` (`id`, `LEGACY_ACCESSION`, `NEW_ACCESSION`) VALUES (1,'ERZ1111','ERZ477708');
10 changes: 10 additions & 0 deletions cypress/integration/assembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,14 @@ describe('Assembly page', function() {
.should('not.exist');
});
});
context('Legacy assemblies redirection', function() {
const legacyAccession = 'ERZ1111';
const redirectUrl = 'assemblies/' + legacyAccession;

it('Should refresh the url and add a callout', function() {
openPage(redirectUrl);
cy.contains('Assembly ' + accession).should('be.visible');
cy.get(".callout").contains("The assembly " + legacyAccession + " has been re-assigned the accession " + accession);
});
});
});
19 changes: 16 additions & 3 deletions src/assembly.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,31 @@
<div class="column small-12 medium-12 large-12">
<nav aria-label="You are here:" role="navigation">
<ul class="breadcrumbs columns">
<li><a href="{{htmlWebpackPlugin.options.templateData.subfolder}}/">Home</a></li>
<li>
<a href="{{htmlWebpackPlugin.options.templateData.subfolder}}/">Home</a>
</li>
<% if (samples.length === 1) { %>
<li><a href="<%= samples[0].url %>">Sample <%= samples[0].id %></a></li>
<li>
<a href="<%= samples[0].url %>">Sample <%= samples[0].id %></a>
</li>
<% } else { %>
<li>Multiple samples</li>
<li>Multiple samples</li>
<% } %>
<li>
<span class="show-for-sr">Current: </span>Assembly <%= assembly_id %>
</li>
</ul>
</nav>
<h2>Assembly <%= assembly_id %></h2>
<% if (legacy_redirection) { %>
<section>
<div class="callout warning">
<p>
The assembly <%= legacy_redirection_accession %> has been re-assigned the accession <a href="<%= analysis_url %>"><%= assembly_id %></a>.
</p>
</div>
</section>
<% } %>
<section id="overview"></section>
<section id="analyses"></section>
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/js/modules/assembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ let AssemblyView = Backbone.View.extend({
data: {},
success(data) {
const attr = data.attributes;
/**
* Handle legacy assemblies redirection.
* Legacy assemblies were given new accessions, the api returns a 302 for those.
* This code handles that case, and shows the user a warning message as the url changes.
*/
that.model.set({legacy_redirection: false});
if (accession !== attr["assembly_id"]) {
that.model.set({
legacy_redirection: true,
legacy_redirection_accession: accession
});
accession = attr["assembly_id"];
window.history.replaceState("", `${objType}: ${accession}`, attr["analysis_url"]);
}
that.render(attr).then(() => {
deferred.resolve();
});
Expand Down Expand Up @@ -141,9 +155,9 @@ let AssemblyAnalysesView = util.GenericTableView.extend({
let assembly = new api.Assembly({id: accession});
let assemblyView = new AssemblyView({model: assembly});

let assemblyAnalyses = new api.AssemblyAnalyses({id: accession});
assemblyView.init()
.then(() => {
let assemblyAnalyses = new api.AssemblyAnalyses({id: accession});
return new AssemblyAnalysesView({collection: assemblyAnalyses});
}).then(() => {
util.attachExpandButtonCallback();
Expand Down

0 comments on commit fe6bbd4

Please sign in to comment.