Skip to content

Commit d4ef128

Browse files
committed
use nested layout to eliminate in_project? check
1 parent d32cc3e commit d4ef128

File tree

5 files changed

+106
-64
lines changed

5 files changed

+106
-64
lines changed

app/controllers/concerns/project_scoped.rb

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module ProjectScoped
77

88
helper :hera
99
helper_method :current_project
10+
layout 'hera/project'
1011
end
1112

1213
protected

app/controllers/projects_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def show
4141
end
4242

4343
respond_to do |format|
44-
format.html { render layout: 'hera' if !request.xhr? }
44+
format.html { render layout: 'hera/project' if !request.xhr? }
4545
format.json { render json: @boards }
4646
end
4747
end

app/helpers/hera_helper.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
module HeraHelper
2+
def body_css
3+
classes = [controller_path.gsub('/', '-'), action_name]
4+
classes << content_for(:body_class) if content_for?(:body_class)
5+
classes.compact.join(' ')
6+
end
7+
28
def colored_icon_for_model(model, icon_class, extra_class = nil)
39
css = ['fa-solid']
410
css << icon_class
@@ -50,10 +56,6 @@ def flash_messages
5056
end.join("\n").html_safe
5157
end
5258

53-
def in_project?
54-
defined?(current_project) && current_project&.persisted?
55-
end
56-
5759
def navbar_brand
5860
if !defined?(Dradis::Pro)
5961
link_to main_app.project_path(current_project), class: 'navbar-brand' do

app/views/layouts/hera.html.erb

+6-59
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,20 @@
3232
<%=
3333
content_tag(
3434
:body,
35-
class: class_names(controller_path.gsub('/', '-'),
36-
controller_name,
37-
action_name,
38-
'in-project': in_project?
39-
),
35+
class: body_css,
4036
data: {
4137
env: (Rails.env unless Rails.env.production?),
4238
}
4339
) do %>
4440

4541
<header class="sticky-top">
4642
<%= render 'layouts/hera/navbar/instance_nav' %>
47-
<%= render 'layouts/hera/navbar/projects/project_nav' if in_project? %>
43+
<%= yield(:sub_nav) if content_for?(:sub_nav) %>
4844
</header>
4945

5046
<div class="content-grid">
5147
<aside>
52-
<%= render 'layouts/hera/sidebar' if in_project? %>
48+
<%= yield(:node_sidebar) if content_for?(:node_sidebar) %>
5349
</aside>
5450
<div class="view-content" data-behavior="view-content">
5551
<main class="container-fluid">
@@ -66,61 +62,12 @@
6662
<% end %>
6763
</div>
6864

69-
<%= render 'activities/poller' if in_project? %>
65+
<%= yield(:poller) if content_for?(:poller) %>
7066

7167
<!-- All modals go here -->
72-
<% if in_project? %>
73-
<%= render 'layouts/hera/modals' %>
74-
<%= render partial: 'nodes/modals/add_node', locals: { type: :branch } %>
68+
<%= yield(:modals) if content_for?(:modals) %>
7569

76-
<% if content_for?(:board_rename_modal) %>
77-
<%= yield(:board_rename_modal) %>
78-
<% end %>
79-
<% if content_for?(:list_new_modal) %>
80-
<%= yield(:list_new_modal) %>
81-
<% end %>
82-
<% if content_for?(:list_rename_modal) %>
83-
<%= yield(:list_rename_modal) %>
84-
<% end %>
85-
86-
<% if content_for?(:bulk_update_modal) %>
87-
<%= yield(:bulk_update_modal) %>
88-
<% end %>
89-
90-
<% if content_for?(:diff_modal) %>
91-
<%= yield(:diff_modal) %>
92-
<% end %>
93-
94-
<% if controller_name == 'boards' || controller_name == 'projects' %>
95-
<%= render 'boards/modals/new_board_form' unless request.xhr? %>
96-
<% end %>
97-
98-
<% if @node && @node.label != 'Methodologies'%>
99-
<%= render partial: 'nodes/modals/add_node', locals: { type: :child } %>
100-
<%= render partial: 'nodes/modals/delete' %>
101-
<%= render partial: 'nodes/modals/merge' %>
102-
<%= render partial: 'nodes/modals/move' %>
103-
<%= render partial: 'nodes/modals/rename' %>
104-
<% end %>
105-
106-
<% if controller_path == 'evidence' %>
107-
<%= render partial: 'evidence/modals/move' %>
108-
<% end %>
109-
110-
<% if controller_name == 'notes'%>
111-
<%= render partial: 'notes/modals/move' %>
112-
<% end %>
113-
114-
<% if controller_name == 'styles_hera' %>
115-
<%= render partial: 'styles_hera/modal' %>
116-
<% end %>
117-
118-
<% if %w[tags issues].include?(controller_name) %>
119-
<%= render partial: 'tags/modals/form' %>
120-
<% end %>
121-
122-
<%= render 'console/console' %>
123-
<% end %>
70+
<%= render 'console/console' %>
12471
<!-- End of modals -->
12572
<% end %>
12673
</html>
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<% content_for :body_class do %>
2+
in-project
3+
<% end %>
4+
5+
<% content_for :sub_nav do %>
6+
<%= render 'layouts/hera/navbar/projects/project_nav' %>
7+
<% end %>
8+
9+
<% content_for :node_sidebar do %>
10+
<%= render 'layouts/hera/sidebar' %>
11+
<% end %>
12+
13+
<% content_for :poller do %>
14+
<%= render 'activities/poller' %>
15+
<% end %>
16+
17+
<% content_for :instance_utility_nav, '' %>
18+
19+
<% content_for :modals do %>
20+
<%= render 'layouts/hera/modals' %>
21+
<%= render partial: 'nodes/modals/add_node', locals: { type: :branch } %>
22+
23+
<% if content_for?(:board_rename_modal) %>
24+
<%= yield(:board_rename_modal) %>
25+
<% end %>
26+
<% if content_for?(:list_new_modal) %>
27+
<%= yield(:list_new_modal) %>
28+
<% end %>
29+
<% if content_for?(:list_rename_modal) %>
30+
<%= yield(:list_rename_modal) %>
31+
<% end %>
32+
33+
<% if content_for?(:bulk_update_modal) %>
34+
<%= yield(:bulk_update_modal) %>
35+
<% end %>
36+
37+
<% if content_for?(:diff_modal) %>
38+
<%= yield(:diff_modal) %>
39+
<% end %>
40+
41+
<% if controller_name == 'boards' || controller_name == 'projects' %>
42+
<%= render 'boards/modals/new_board_form' unless request.xhr? %>
43+
<% end %>
44+
45+
<% if @node && @node.label != 'Methodologies'%>
46+
<%= render partial: 'nodes/modals/add_node', locals: { type: :child } %>
47+
<%= render partial: 'nodes/modals/delete' %>
48+
<%= render partial: 'nodes/modals/merge' %>
49+
<%= render partial: 'nodes/modals/move' %>
50+
<%= render partial: 'nodes/modals/rename' %>
51+
<% end %>
52+
53+
<% if controller_path == 'evidence' %>
54+
<%= render partial: 'evidence/modals/move' %>
55+
<% end %>
56+
57+
<% if controller_name == 'notes'%>
58+
<%= render partial: 'notes/modals/move' %>
59+
<% end %>
60+
61+
<% if controller_name == 'styles_hera' %>
62+
<%= render partial: 'styles_hera/modal' %>
63+
<% end %>
64+
65+
<% if %w[tags issues].include?(controller_name) %>
66+
<%= render partial: 'tags/modals/form' %>
67+
<% end %>
68+
<% end %>
69+
70+
<% content_for :search do %>
71+
<li class="nav-item d-lg-none">
72+
<%= render "layouts/hera/navbar/projects/search" %>
73+
</li>
74+
<% end %>
75+
76+
<% content_for :notifications do %>
77+
<%= link_to main_app.project_notifications_path(current_project),
78+
class: 'nav-link dropdown-toggle no-caret',
79+
id: 'notifications',
80+
data: {
81+
bs_toggle: 'dropdown',
82+
behavior: 'notifications-dropdown close-collapse',
83+
project_id: current_project.id
84+
},
85+
role: 'button',
86+
'aria-expanded': 'false' do %>
87+
<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>
88+
<span class="d-inline d-lg-none">Notifications</span>
89+
<% end %>
90+
<% end %>
91+
92+
<%= render template: "layouts/hera" %>

0 commit comments

Comments
 (0)