Skip to content

Commit 53d6df2

Browse files
authored
Merge branch 'develop' into sidebar/collapse-conditionally
2 parents ec46594 + a995c00 commit 53d6df2

File tree

10 files changed

+78
-49
lines changed

10 files changed

+78
-49
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[v#.#.#] ([month] [YYYY])
2+
- Activities: remove ActivityTracking for Issues and use EventPublisher
23
- Profile: update default user avatar
34
- Forms: Improve visibility of form actions
45
- Docker:

app/controllers/issues/merge_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Issues::MergeController < IssuesController
2-
32
def new
43
@issues = []
54

@@ -22,8 +21,8 @@ def create
2221
if @issue.new_record?
2322
@issue.author ||= current_user.email
2423
if @issue.save && @issue.update(issue_params)
25-
track_created(@issue)
2624
@issue.tag_from_field_content!
25+
publish_event('issue.created', @issue.to_event_payload)
2726
end
2827
end
2928

app/controllers/issues_controller.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class IssuesController < AuthenticatedController
2-
include ActivityTracking
32
include ConflictResolver
43
include ContentFromTemplate
54
include DynamicFieldNamesCacher
5+
include EventPublisher
66
include IssuesHelper
77
include LiquidEnabledResource
88
include Mentioned
@@ -47,22 +47,21 @@ def create
4747

4848
respond_to do |format|
4949
if @issue.save &&
50-
# FIXME: need to fix Taggable concern.
51-
#
52-
# For some reason we can't save the :tags before we save the model,
53-
# so first we save it, then we apply the tags.
54-
#
55-
# See #set_or_initialize_issue()
56-
#
57-
@issue.update(issue_params)
58-
59-
track_created(@issue)
50+
# FIXME: need to fix Taggable concern.
51+
#
52+
# For some reason we can't save the :tags before we save the model,
53+
# so first we save it, then we apply the tags.
54+
#
55+
# See #set_or_initialize_issue()
56+
#
57+
@issue.update(issue_params)
6058

6159
# Only after we save the issue, we can create valid taggings (w/ valid
6260
# taggable IDs)
6361
@issue.tag_from_field_content!
6462

6563
format.html { redirect_to [current_project, @issue], notice: 'Issue added.' }
64+
publish_event('issue.created', @issue.to_event_payload)
6665
else
6766
format.html do
6867
flash.now[:alert] = 'Issue couldn\'t be added.'
@@ -84,8 +83,8 @@ def update
8483
if @issue.update(issue_params)
8584
@modified = true
8685
check_for_edit_conflicts(@issue, updated_at_before_save)
87-
track_updated(@issue)
8886
format.html { redirect_to_main_or_qa }
87+
publish_event('issue.updated', @issue.to_event_payload)
8988
else
9089
format.html do
9190
flash.now[:alert] = 'Issue couldn\'t be updated.'
@@ -100,9 +99,9 @@ def update
10099
def destroy
101100
respond_to do |format|
102101
if @issue.destroy
103-
track_destroyed(@issue)
104102
format.html { redirect_to project_issues_path(current_project), notice: 'Issue deleted.' }
105103
format.json
104+
publish_event('issue.destroyed', @issue.to_event_payload)
106105
else
107106
format.html { redirect_to project_issues_path(current_project), notice: "Error while deleting issue: #{@issue.errors}" }
108107
format.json

app/models/issue.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Issue < Note
22
include Commentable
3+
include Eventable
34
# FIXME - ISSUE/NOTE INHERITANCE
45
# Commentable.allowed_types << base.name doesn't work for Issue because it's
56
# an STI model, so we manually allow the class here.
@@ -116,6 +117,21 @@ def evidence_by_node()
116117
end
117118
end
118119

120+
# Returns a hash that will be used as part of event notification workflows.
121+
def local_event_payload
122+
{
123+
author: author,
124+
project: {
125+
id: project.id,
126+
name: project.name
127+
},
128+
state: state,
129+
tag: tags.first,
130+
fields: fields,
131+
title: title
132+
}
133+
end
134+
119135
# Move all Evidence attached to issues with ids in issue_ids
120136
# array to current issue.
121137
# Then delete those issues without Evidence.
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
<% cache('navbar') do %>
12
<nav class="navbar navbar-expand-lg main-nav">
2-
<div class="container-fluid">
3-
<%= navbar_brand %>
3+
<div class="container-fluid">
4+
<%= navbar_brand %>
45

5-
<button class="navbar-toggler" type="button" data-behavior="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".dual-nav" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
6-
<i class="fa-solid fa-bars"></i>
7-
</button>
6+
<button class="navbar-toggler" type="button" data-behavior="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".dual-nav" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
7+
<i class="fa-solid fa-bars"></i>
8+
</button>
89

9-
<div class="collapse navbar-collapse justify-content-end dual-nav" data-behavior="navbar-collapse">
10-
<ul class="navbar-nav navbar-nav-scroll me-auto pb-0">
11-
<%= render "layouts/hera/navbar/main_nav/#{Dradis.edition}" %>
12-
</ul>
10+
<div class="collapse navbar-collapse justify-content-end dual-nav" data-behavior="navbar-collapse">
11+
<ul class="navbar-nav navbar-nav-scroll me-auto pb-0">
12+
<%= render "layouts/hera/navbar/main_nav/#{Dradis.edition}" %>
13+
</ul>
1314

14-
<%= render 'layouts/hera/navbar/main_nav/utility_nav' %>
15+
<%= render 'layouts/hera/navbar/main_nav/utility_nav' %>
16+
</div>
1517
</div>
16-
</div>
17-
</nav>
18+
</nav>
19+
<% end %>

app/views/layouts/hera/navbar/main_nav/_ce.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
<span>Projects</span>
77
<% end %>
88
</li>
9-
<%= render 'layouts/hera/navbar/main_nav/tools_menu' %>
9+
10+
<% cache(['navbar-tools', Dradis::Plugins.with_feature(:addon)]) do %>
11+
<%= render 'layouts/hera/navbar/main_nav/tools_menu' %>
12+
<% end %>

app/views/layouts/hera/navbar/main_nav/utility_nav/_ce.html.erb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@
77

88
<%= render partial: 'layouts/hera/navbar/main_nav/utility_nav/configuration_menu' %>
99

10-
<li class="nav-item notifications dropdown">
11-
<%= link_to main_app.project_notifications_path(current_project),
12-
class: 'nav-link dropdown-toggle no-caret',
13-
data: {
14-
id: 'notifications',
15-
bs_toggle: 'dropdown',
16-
behavior: 'notifications-dropdown close-collapse',
17-
project_id: current_project.id
18-
},
19-
role: 'button',
20-
'aria-expanded': 'false' do %>
21-
<i class="notifications-bell fa-solid fa-bell d-none d-lg-inline" title="Notifications"><i class="notifications-dot d-none" data-behavior="notifications-dot"></i></i>
22-
<span class="d-inline d-lg-none">Notifications</span>
23-
<% end %>
24-
<div class="dropdown-menu dropdown-menu-end" data-url="<%= main_app.notifications_path %>" aria-labelledby="notifications">
25-
</div>
26-
</li>
10+
<% cache(['navbar-notifications', current_user.notifications.unread]) do %>
11+
<li class="nav-item notifications dropdown">
12+
<%= link_to main_app.project_notifications_path(current_project),
13+
class: 'nav-link dropdown-toggle no-caret',
14+
data: {
15+
id: 'notifications',
16+
bs_toggle: 'dropdown',
17+
behavior: 'notifications-dropdown close-collapse',
18+
project_id: current_project.id
19+
},
20+
role: 'button',
21+
'aria-expanded': 'false' do %>
22+
<i class="notifications-bell fa-solid fa-bell d-none d-lg-inline" title="Notifications"><i class="notifications-dot d-none" data-behavior="notifications-dot"></i></i>
23+
<span class="d-inline d-lg-none">Notifications</span>
24+
<% end %>
25+
<div class="dropdown-menu dropdown-menu-end" data-url="<%= main_app.notifications_path %>" aria-labelledby="notifications">
26+
</div>
27+
</li>
28+
<% end %>
29+
2730
<%= render partial: 'layouts/hera/navbar/main_nav/help_menu' %>
2831

2932
<li class="nav-item dropdown me-0 mb-3 mb-lg-0">
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Rails.application.reloader.to_prepare do
2+
ActivityService.configure do |activity_service|
3+
activity_service.subscribe_namespace 'issue'
4+
end
5+
end

engines/dradis-api/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
v3 (Aug 2023)
22
- Add Boards, Lists, Cards endpoints.
3+
- Track activities using published events

engines/dradis-api/app/controllers/dradis/ce/api/v3/issues_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Dradis::CE::API
22
module V3
33
class IssuesController < Dradis::CE::API::APIController
4-
include ActivityTracking
4+
include EventPublisher
55
include Dradis::CE::API::ProjectScoped
66

77
before_action :set_issue, except: [:index]
@@ -23,8 +23,8 @@ def create
2323
@issue.node = current_project.issue_library
2424

2525
if @issue.save
26-
track_created(@issue)
2726
@issue.tag_from_field_content!
27+
publish_event('issue.created', @issue.to_event_payload)
2828
render status: 201, location: dradis_api.issue_url(@issue)
2929
else
3030
render_validation_errors(@issue)
@@ -33,7 +33,7 @@ def create
3333

3434
def update
3535
if @issue.update(issue_params)
36-
track_updated(@issue)
36+
publish_event('issue.updated', @issue.to_event_payload)
3737
render node: @node
3838
else
3939
render_validation_errors(@issue)
@@ -42,7 +42,7 @@ def update
4242

4343
def destroy
4444
@issue.destroy
45-
track_destroyed(@issue)
45+
publish_event('issue.destroyed', @issue.to_event_payload)
4646
render_successful_destroy_message
4747
end
4848

0 commit comments

Comments
 (0)