Skip to content

Commit

Permalink
Adds liquid display support for issue titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostas Sklias committed Jan 29, 2024
1 parent 5c02515 commit 04120cc
Show file tree
Hide file tree
Showing 23 changed files with 44 additions and 31 deletions.
1 change: 1 addition & 0 deletions app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# users.

class ActivitiesController < AuthenticatedController
include LiquidEnabledResource
include ProjectScoped

def index
Expand Down
1 change: 1 addition & 0 deletions app/controllers/evidence_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class EvidenceController < NestedNodeResourceController
include MultipleDestroy
include NodesSidebar
include NotificationsReader
include ProjectScoped

before_action :set_or_initialize_evidence, except: [ :index, :create_multiple ]
before_action :initialize_nodes_sidebar, only: [ :edit, :new, :show ]
Expand Down
1 change: 1 addition & 0 deletions app/controllers/issues/evidence_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Issues::EvidenceController < AuthenticatedController
include ActivityTracking
include ContentFromTemplate
include DynamicFieldNamesCacher
include LiquidEnabledResource
include MultipleDestroy
include ProjectScoped

Expand Down
1 change: 1 addition & 0 deletions app/controllers/nested_node_resource_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class NestedNodeResourceController < AuthenticatedController
include ActivityTracking
include ContentFromTemplate
include LiquidEnabledResource
include ProjectScoped

before_action :find_or_initialize_node
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ProjectsController < AuthenticatedController
include LiquidEnabledResource
include NotificationsReader

before_action :set_project
Expand All @@ -16,12 +17,12 @@ def show
@authors = [current_user]
@boards = current_project.methodology_library.boards
@issues = current_project.issues.includes(:tags).sort
@methodologies = current_project.methodology_library.notes.map{|n| Methodology.new(filename: n.id, content: n.text)}
@methodologies = current_project.methodology_library.notes.map { |n| Methodology.new(filename: n.id, content: n.text) }
@nodes = current_project.nodes.in_tree
@tags = current_project.tags

@count_by_tag = { unassigned: 0 }
@issues_by_tag = Hash.new{|h,k| h[k] = [] }
@issues_by_tag = Hash.new { |h, k| h[k] = [] }

@tag_names = @tags.map do |tag|
@count_by_tag[tag.name] = 0
Expand All @@ -41,7 +42,7 @@ def show
end

respond_to do |format|
format.html { render layout: 'tylium' if !request.xhr?}
format.html { render layout: 'tylium' if !request.xhr? }
format.json { render json: @boards }
end
end
Expand Down
15 changes: 9 additions & 6 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class SearchController < AuthenticatedController
include LiquidEnabledResource
include ProjectScoped
include SearchHelper

Expand All @@ -15,11 +16,13 @@ def index

private
def set_scope
@scope = if params[:scope].blank? ||
!%{all evidence issues nodes notes}.include?(params[:scope])
:all
else
params[:scope].to_sym
end
@scope =
if params[:scope].blank? ||
!%{all cards content_blocks evidence issues nodes notes}.\
include?(params[:scope])
:all
else
params[:scope].to_sym
end
end
end
6 changes: 5 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ApplicationHelper # :nodoc:
def markup(text, options={})
def markup(text, options = {})
return unless text.present?

context = {}
Expand Down Expand Up @@ -27,6 +27,10 @@ def markup(text, options={})
result[:output].to_s.html_safe
end

def liquid_text(text)
strip_tags(markup(text, liquid: true))
end

def render_view_hooks(partial, locals: {}, feature: :addon)
Dradis::Plugins::with_feature(feature).sort_by(&:plugin_description).each do |plugin|
begin
Expand Down
2 changes: 1 addition & 1 deletion app/views/evidence/activities/_evidence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% node = evidence.node %>
<%= presenter.verb %> <%= link_to 'a piece of evidence', [current_project, node, evidence] %>
for
<%= link_to issue.title || "Issue #{issue.id}", [current_project, evidence.issue] %> at <%= link_to node.label, [current_project, node] %>.
<%= link_to liquid_text(issue.title) || "Issue #{issue.id}", [current_project, evidence.issue] %> at <%= link_to node.label, [current_project, node] %>.
<% else %>
<% if activity.action == 'destroy' %>
deleted a piece of evidence.
Expand Down
2 changes: 1 addition & 1 deletion app/views/evidence/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "Edit evidence for #{@node.label} / #{@evidence.issue.title}" %>
<% content_for :title, "Edit evidence for #{@node.label} / #{liquid_text(@evidence.issue.title)}" %>
<% content_for :breadcrumbs do %>
<nav>
Expand Down
2 changes: 1 addition & 1 deletion app/views/evidence/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, "View evidence for #{@node.label} / #{@evidence.issue.title}" %>
<% content_for :title, "View evidence for #{@node.label} / #{liquid_text(@evidence.issue.title)}" %>
<% if @conflicting_revisions %>
<%= render "projects/conflicting_revisions", conflicts: @conflicting_revisions, record: @evidence %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/_breadcrumbs.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><%= link_to 'All issues', project_issues_path(current_project) %></li>
<li class="breadcrumb-item active"><%= (@issue.title? ? @issue.title : "Issue ##{@issue.id}")%></li>
<li class="breadcrumb-item active"><%= (@issue.title? ? liquid_text(@issue.title) : "Issue ##{@issue.id}")%></li>
</ol>
</nav>
4 changes: 2 additions & 2 deletions app/views/issues/_issue.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
%>
<%= content_tag :div, id: "#{dom_id(issue)}_link", class: item_css.join do %>
<%= link_to main_app.project_issue_path(current_project, issue) do %>
<%= link_to main_app.project_issue_path(current_project, issue) do %>
<%= colored_icon_for_model(issue, 'fa-bug', 'list-item-icon') %>
<%= issue.title %>
<%= liquid_text(issue.title) %>
<% end %>

<div class="list-item-actions">
Expand Down
3 changes: 2 additions & 1 deletion app/views/issues/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
<tr id="issue-<%= issue.id %>" data-tag-url="<%= project_issue_path(current_project, issue) %>">
<td class="select-checkbox" data-behavior="select-checkbox"></td>
<% @all_columns.each do |column| %>
<% title = strip_tags(markup(issue.title, liquid: true)) %>
<% sort, display =
case column
when 'Title'
[issue.title, (link_to(issue.title, [current_project, issue], data: { qa_visible: false } ) + link_to(issue.title, project_qa_issue_path(current_project, issue), class: 'd-none', data: { qa_visible: true }))]
[title, (link_to(title, [current_project, issue], data: { qa_visible: false } ) + link_to(title, project_qa_issue_path(current_project, issue), class: 'd-none', data: { qa_visible: true }))]
when 'Tags'
[
issue.tags.any? ? issue.tags.first.display_name : '',
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/activities/_issue.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if issue %>
<% if issue.title? %>
<%= presenter.verb %> the <%= link_to issue.title, project_issue_path(current_project, issue) %> <%= activity.action == 'state_change' ? "issue's state to #{issue.state.humanize.downcase}" : 'issue' %>.
<%= presenter.verb %> the <%= link_to liquid_text(issue.title), project_issue_path(current_project, issue) %> <%= activity.action == 'state_change' ? "issue's state to #{issue.state.humanize.downcase}" : 'issue' %>.
<% else %>
<%= presenter.verb %> <%= link_to "Issue ##{issue.id}", project_issue_path(current_project, issue) %>.
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/evidence/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
when 'Updated'
[evidence.updated_at.to_i, local_time_ago(evidence.updated_at)]
else
[evidence.fields.fetch(column, ''), markup(evidence.fields.fetch(column, ''))]
[evidence.fields.fetch(column, ''), liquid_text(evidence.fields.fetch(column, ''))]
end
%>
<td data-sort="<%= sort %>"><%= display %></td>
Expand Down
6 changes: 3 additions & 3 deletions app/views/issues/evidence/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<% content_for :title, "Add new evidence for #{@issue.title}" %>
<% content_for :title, "Add new evidence for #{ liquid_text(@issue.title) }" %>
<% content_for :breadcrumbs do %>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><%= link_to 'All issues', project_issues_path(current_project) %></li>
<li class="breadcrumb-item"><%= link_to @issue.title, project_issue_path(current_project, @issue, tab: 'evidence-tab') %></li>
<li class="breadcrumb-item"><%= link_to liquid_text(@issue.title), project_issue_path(current_project, @issue, tab: 'evidence-tab') %></li>
<li class="breadcrumb-item active">New Evidence</li>
</ol>
</nav>
Expand All @@ -29,7 +29,7 @@
<div id="issues_editor">
<div class="note-text-inner">
<h4 class="header-underline">Add new evidence</h4>
<p class="mb-4 pb-3">Add evidence of <em><%= @issue.title ? @issue.title : "Issue ##{@issue.id}" %></em> by selecting or adding nodes below.</p>
<p class="mb-4 pb-3">Add evidence of <em><%= @issue.title ? liquid_text(@issue.title) : "Issue ##{@issue.id}" %></em> by selecting or adding nodes below.</p>
<div class="row">

<div class="col-xl-4">
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/import.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
sort, display =
case column
when 'Title'
[issue.title, issue.title]
[liquid_text(issue.title), liquid_text(issue.title)]
when 'Tags'
[issue_tags(issue), issue_tags(issue)]
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/merge/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="radio">
<%= label_tag nil, :class => 'w-100' do %>
<%= radio_button_tag "id", issue.id, i == 0 %>
Merge into <%= issue.title %>
Merge into <%= liquid_text(issue.title) %>
<%= link_to raw('<i class="fa-solid fa-chevron-down"></i>'), "#preview_issue_#{issue.id}", class: 'issue-toggle pull-right', data: { bs_toggle: 'collapse' } %>
<% end %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/issues/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :title, @issue.title %>
<% content_for :title, liquid_text(@issue.title) %>
<% content_for :sidebar do %>
<%= render 'sidebar'%>
Expand Down Expand Up @@ -32,7 +32,7 @@
<% cache ['issue-information-tab', @issue] do %>
<div class="note-text-inner">
<h4 class="mb-4 header-underline">
<span class="text-truncate" title="<%= @issue.title %>"><%= @issue.title %></span>
<span class="text-truncate" title="<%= liquid_text(@issue.title) %>"><%= liquid_text(@issue.title) %></span>
<%= render partial: 'actions' %>
</h4>
<div class="content-textile" data-behavior="content-textile">
Expand Down
4 changes: 2 additions & 2 deletions app/views/projects/issues/_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ul class="list-group">
<% @issues_by_tag[tag.name].each do |issue| %>
<%= link_to [current_project, issue], class: 'list-group-item' do %>
<li><i class="fa-solid fa-bug me-2" style="color: <%= tag.color %>"></i><%= issue.title %></li>
<li><i class="fa-solid fa-bug me-2" style="color: <%= tag.color %>"></i><%= liquid_text(issue.title) %></li>
<% end %>
<% end %>
</ul>
Expand All @@ -38,7 +38,7 @@
<ul class="list-group">
<% @issues_by_tag[:unassigned].each do |issue| %>
<%= link_to [current_project, issue], class: 'list-group-item' do %>
<li><i class="fa-solid fa-bug me-2"></i><%= issue.title %></li>
<li><i class="fa-solid fa-bug me-2"></i><%= liquid_text(issue.title) %></li>
<% end %>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/qa/issues/_breadcrumbs.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><%= link_to 'QA', project_qa_issues_path(current_project) %></li>
<li class="breadcrumb-item active"><%= (@issue.title? ? @issue.title : "Issue ##{@issue.id}")%></li>
<li class="breadcrumb-item active"><%= (@issue.title? ? liquid_text(@issue.title) : "Issue ##{@issue.id}")%></li>
</ol>
</nav>
2 changes: 1 addition & 1 deletion app/views/qa/issues/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<% cache ['issue-content', @issue] do %>
<div class="note-text-inner">
<h4 class="mb-4 header-underline align-items-center">
<span class="text-truncate" title="<%= @issue.title %>"><%= @issue.title %></span>
<span class="text-truncate" title="<%= liquid_text(@issue.title) %>"><%= liquid_text(@issue.title) %></span>
<span class="actions">
<span class="action">
<%= link_to edit_project_qa_issue_path(current_project, @issue) do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/results/_evidence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= link_to title, project_node_evidence_path(row.node.project, row.node_id, row), class: "search-match-title" %>

<div class="result-details">
<p><span>Issue:</span> <%= link_to row.issue.title, project_issue_path(current_project, row.issue) %></p>
<p><span>Issue:</span> <%= link_to liquid_text(row.issue.title), project_issue_path(current_project, row.issue) %></p>
<p><span>Node:</span> <%= link_to row.node.label, project_node_path(row.node.project, row.node) %></p>
<p><span>Last updated:</span> <%= local_time_ago(row.updated_at) %></p>
</div>
Expand Down

0 comments on commit 04120cc

Please sign in to comment.