-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batch sample import activities (#971)
* add metadata parsing * rework empty metadata handling * activities for projects and groups * Fix group sample activity * fix wrong usage of include_activity in workflow completion service * update keys * fix duplication in activity component * removed unneeded parent class * try updating sapporo build instructions * undo sapporo change * add tests * fix test name clash * update activity counts * fix modules
- Loading branch information
1 parent
c89a33a
commit 236f2f9
Showing
17 changed files
with
208 additions
and
18 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/components/activities/groups/sample_activity_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<span> | ||
<% if import_samples_action %> | ||
<%= t( | ||
"#{@activity[:key]}", | ||
user: @activity[:user], | ||
href: | ||
link_to( | ||
@activity[:imported_samples_count], | ||
"#", | ||
class: "text-slate-800 dark:text-slate-300 font-medium cursor-not-allowed", | ||
disabled: true, | ||
), | ||
) %> | ||
<% end %> | ||
</span> |
16 changes: 16 additions & 0 deletions
16
app/components/activities/groups/sample_activity_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Activities | ||
module Groups | ||
# Component for rendering an group sample activity | ||
class SampleActivityComponent < Component | ||
def initialize(activity: nil) | ||
@activity = activity | ||
end | ||
|
||
def import_samples_action | ||
@activity[:action] == 'import_samples' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'view_component_test_case' | ||
|
||
module Groups | ||
class SampleActivityComponentTest < ViewComponentTestCase | ||
include ActionView::Helpers::SanitizeHelper | ||
|
||
setup do | ||
@user = users(:john_doe) | ||
end | ||
|
||
test 'batch sample import actvity' do | ||
group = groups(:group_one) | ||
activities = group.human_readable_activity(group.retrieve_group_activity).reverse | ||
|
||
assert_equal(1, activities.count do |activity| | ||
activity[:key].include?('group.import_samples.create') | ||
end) | ||
|
||
activity_to_render = activities.find do |a| | ||
a[:key] == 'activity.group.import_samples.create_html' | ||
end | ||
|
||
render_inline Activities::Groups::SampleActivityComponent.new(activity: activity_to_render) | ||
|
||
assert_text strip_tags( | ||
I18n.t('activity.group.import_samples.create_html', | ||
user: 'System', | ||
href: 2) | ||
) | ||
assert_selector 'a', | ||
text: 2 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.