Skip to content
Snippets Groups Projects

Search for label on project labels page by title or description

Merged Dmytro Zaporozhets (DZ) requested to merge dz-labels-search into master
All threads resolved!
Files
2
@@ -2,32 +2,45 @@
@@ -2,32 +2,45 @@
- page_title "Labels"
- page_title "Labels"
- can_admin_label = can?(current_user, :admin_label, @project)
- can_admin_label = can?(current_user, :admin_label, @project)
- hide_class = ''
- hide_class = ''
 
- search = params[:search]
- if can_admin_label
- if can_admin_label
- content_for(:header_content) do
- content_for(:header_content) do
.nav-controls
.nav-controls
= link_to _('New label'), new_project_label_path(@project), class: "btn btn-new"
= link_to _('New label'), new_project_label_path(@project), class: "btn btn-new"
- if @labels.exists? || @prioritized_labels.exists?
- if @labels.exists? || @prioritized_labels.exists? || search.present?
#promote-label-modal
#promote-label-modal
%div{ class: container_class }
%div{ class: container_class }
.top-area.adjust
.top-area.adjust
.nav-text
.nav-text
= _('Labels can be applied to issues and merge requests.')
= _('Labels can be applied to issues and merge requests.')
- if can_admin_label
= _('Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging.')
.labels-container.prepend-top-5
.nav-controls
 
= form_tag project_labels_path(@project), method: :get do
 
.input-group
 
= search_field_tag :search, params[:search], { placeholder: _('Filter'), id: 'label-search', class: 'form-control search-text-input input-short', spellcheck: false }
 
%span.input-group-append
 
%button.btn.btn-default{ type: "submit", "aria-label" => _('Submit search') }
 
= icon("search")
 
 
.labels-container.prepend-top-10
- if can_admin_label
- if can_admin_label
 
- if search.blank?
 
%p.text-muted
 
= _('Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging.')
-# Only show it in the first page
-# Only show it in the first page
- hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1')
- hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1')
.prioritized-labels{ class: ('hide' if hide) }
.prioritized-labels{ class: ('hide' if hide) }
%h5.prepend-top-10= _('Prioritized Labels')
%h5.prepend-top-10= _('Prioritized Labels')
.content-list.manage-labels-list.js-prioritized-labels{ "data-url" => set_priorities_project_labels_path(@project) }
.content-list.manage-labels-list.js-prioritized-labels{ "data-url" => set_priorities_project_labels_path(@project) }
#js-priority-labels-empty-state.priority-labels-empty-state{ class: "#{'hidden' unless @prioritized_labels.empty?}" }
#js-priority-labels-empty-state.priority-labels-empty-state{ class: "#{'hidden' unless @prioritized_labels.empty? && search.blank?}" }
= render 'shared/empty_states/priority_labels'
= render 'shared/empty_states/priority_labels'
- if @prioritized_labels.present?
- if @prioritized_labels.present?
= render partial: 'shared/label', subject: @project, collection: @prioritized_labels, as: :label, locals: { force_priority: true }
= render partial: 'shared/label', subject: @project, collection: @prioritized_labels, as: :label, locals: { force_priority: true }
 
- elsif search.present?
 
.nothing-here-block
 
= _('No prioritised labels with such name or description')
- if @labels.present?
- if @labels.present?
.other-labels
.other-labels
@@ -36,6 +49,18 @@
@@ -36,6 +49,18 @@
.content-list.manage-labels-list.js-other-labels
.content-list.manage-labels-list.js-other-labels
= render partial: 'shared/label', subject: @project, collection: @labels, as: :label
= render partial: 'shared/label', subject: @project, collection: @labels, as: :label
= paginate @labels, theme: 'gitlab'
= paginate @labels, theme: 'gitlab'
 
- elsif search.present?
 
.other-labels
 
- if @available_labels.any?
 
%h5
 
= _('Other Labels')
 
.nothing-here-block
 
= _('No other labels with such name or description')
 
- else
 
.nothing-here-block
 
= _('No labels with such name or description')
 
 
- else
- else
= render 'shared/empty_states/labels'
= render 'shared/empty_states/labels'
Loading