Skip to content

Commit 54c3a12

Browse files
authored
Merge pull request #2357 from broadinstitute/jb-duos-link-updates
Linking from SCP to DUOS entries (SCP-6108)
2 parents a2e5d10 + 8d5dd95 commit 54c3a12

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

app/assets/images/duos-logo.svg

Lines changed: 1 addition & 0 deletions
Loading

app/javascript/styles/_brand.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,7 @@
325325
float: right;
326326
margin-top: 3px;
327327
}
328+
329+
.duos-logo {
330+
height: 48px;
331+
object-fit: scale-down;}

app/lib/duos_registration_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class DuosRegistrationService
77
# * *returns*
88
# - (String) DUOS UI base URL, based on environment
99
def self.duos_ui_url
10-
Rails.env.production? ? 'https://duos.org' : 'https://duos-k8s.dsde-dev.broadinstitute.org/'
10+
Rails.env.production? ? 'https://duos.org' : 'https://duos-k8s.dsde-dev.broadinstitute.org'
1111
end
1212

1313
# API client

app/models/study.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,11 @@ def viewable_metadata
11001100

11011101
# helper to determine if a study has any publications/external resources to link to from the study overview page
11021102
def has_sidebar_content?
1103-
publications.any? || external_resources.any? || authors.corresponding.any?
1103+
publications.any? || authors.corresponding.any? || has_resource_links?
1104+
end
1105+
1106+
def has_resource_links?
1107+
external_resources.any? || duos_study_id.present?
11041108
end
11051109

11061110
###

app/views/single_cell_mailer/duos_error.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<html lang="en">
22
<body>
3-
<p>The following error occurred when trying to <strong><%= @action %></strong> <%= @study.accession %> in DUOS:</p>
3+
<p>The following error occurred when trying to <strong><%= @action %></strong>
4+
<%= link_to @study.accession, view_study_url(accession: @study.accession, study_name: @study.url_safe_name) %>
5+
in DUOS</p>.
6+
<p>This error occurred in the '<%= Rails.env %>' environment.</p>
47
<pre>
58
<%= @error_message %>
69
</pre>

app/views/site/_study_resources_sidebar.html.erb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<br/><br/>
3434
<% end %>
3535
<% end %>
36-
<% if @study.external_resources.any? %>
36+
<% if @study.has_resource_links? %>
3737
<h5>Resources</h5>
3838
<% @study.external_resources.each do |resource| %>
3939
<p>
@@ -45,5 +45,14 @@
4545

4646
</p>
4747
<% end %>
48+
<% if @study.duos_study_id.present? %>
49+
<p>
50+
<%= link_to image_tag('duos-logo.svg', alt: 'DUOS logo', class: 'duos-logo'),
51+
@study.duos_study_url,
52+
class: 'navigation-form external-resource-link',
53+
target: :_blank, rel: 'noopener', title: "View study in DUOS",
54+
data: { toggle: 'tooltip', 'analytics-name' => 'duos-link' } %>
55+
</p>
56+
<% end %>
4857
<% end %>
4958
</div>

test/models/study_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,21 @@ class StudyTest < ActiveSupport::TestCase
300300
'You must have an organizational email associated with your account'
301301
)
302302
end
303+
304+
test 'should determine if study has resource links' do
305+
study = FactoryBot.create(:detached_study,
306+
user: @user,
307+
name_prefix: 'Resource Link Test',
308+
test_array: @@studies_to_clean)
309+
assert_not study.has_resource_links?
310+
ext_resource = study.external_resources.build(url: 'https://www.google.com', title: 'Google')
311+
ext_resource.save!
312+
assert study.has_resource_links?
313+
ext_resource.destroy
314+
study.reload
315+
assert_not study.has_resource_links?
316+
duos_study_id = rand(1000..9999)
317+
study.update(duos_study_id:)
318+
assert study.has_resource_links?
319+
end
303320
end

0 commit comments

Comments
 (0)