Commit e5ae43e2 authored by Luke Bennett's avatar Luke Bennett

Start changing group label page

parent a72fc8e6
...@@ -2,27 +2,20 @@ class Groups::LabelsController < Groups::ApplicationController ...@@ -2,27 +2,20 @@ class Groups::LabelsController < Groups::ApplicationController
include ToggleSubscriptionAction include ToggleSubscriptionAction
before_action :label, only: [:edit, :update, :destroy] before_action :label, only: [:edit, :update, :destroy]
before_action :find_labels, only: [:index]
before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :destroy] before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :destroy]
before_action :save_previous_label_path, only: [:edit] before_action :save_previous_label_path, only: [:edit]
respond_to :html respond_to :html
def index def index
respond_to do |format| @prioritized_labels = @available_labels.prioritized(@group)
format.html do @labels = @available_labels.unprioritized(@group).page(params[:page])
@labels = @group.labels.page(params[:page])
end
respond_to do |format|
format.html
format.json do format.json do
available_labels = LabelsFinder.new( render json: LabelSerializer.new.represent_appearance(@available_labels)
current_user,
group_id: @group.id,
only_group_labels: params[:only_group_labels],
include_ancestor_groups: params[:include_ancestor_groups],
include_descendant_groups: params[:include_descendant_groups]
).execute
render json: LabelSerializer.new.represent_appearance(available_labels)
end end
end end
end end
...@@ -113,4 +106,15 @@ class Groups::LabelsController < Groups::ApplicationController ...@@ -113,4 +106,15 @@ class Groups::LabelsController < Groups::ApplicationController
def save_previous_label_path def save_previous_label_path
session[:previous_labels_path] = URI(request.referer || '').path session[:previous_labels_path] = URI(request.referer || '').path
end end
def find_labels
@available_labels ||=
LabelsFinder.new(
current_user,
group_id: @group.id,
only_group_labels: params[:only_group_labels],
include_ancestor_groups: params[:include_ancestor_groups],
include_descendant_groups: params[:include_descendant_groups]
).execute
end
end end
- page_title 'Labels' - @no_container = true
- page_title "Labels"
- can_admin_label = can?(current_user, :admin_label, @group)
- hide_class = ''
- issuables = ['issues', 'merge requests'] - if can_admin_label
- content_for(:header_content) do
.nav-controls
= link_to new_group_label_path(@group), class: "btn btn-new" do
New label
.top-area.adjust - if @labels.exists? || @prioritized_labels.exists?
.nav-text #promote-label-modal
= _("Labels can be applied to %{features}. Group labels are available for any project within the group.") % { features: issuables.to_sentence } %div{ class: container_class }
.top-area.adjust
.nav-text
Labels can be applied to issues, merge requests and epics. Group labels are available for any project within the group.
- if can_admin_label
Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging.
.nav-controls .labels-container.prepend-top-5
- if can?(current_user, :admin_label, @group) - if can_admin_label
= link_to "New label", new_group_label_path(@group), class: "btn btn-new" -# Only show it in the first page
- hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1')
.prioritized-labels{ class: ('hide' if hide) }
%h5.prepend-top-0 Prioritized Labels
%ul.content-list.manage-labels-list.js-prioritized-labels
#js-priority-labels-empty-state{ class: "#{'hidden' unless @prioritized_labels.empty?}" }
= render 'shared/empty_states/priority_labels'
- if @prioritized_labels.present?
= render partial: 'shared/label', subject: @group, collection: @prioritized_labels, as: :label
.labels - if @labels.present?
.other-labels .other-labels
- if @labels.present? - if can_admin_label
%ul.content-list.manage-labels-list.js-other-labels %h5{ class: ('hide' if hide) } Other Labels
= render partial: 'shared/label', subject: @group, collection: @labels, as: :label %ul.content-list.manage-labels-list.js-other-labels
= paginate @labels, theme: 'gitlab' = render partial: 'shared/label', subject: @group, collection: @labels, as: :label
- else = paginate @labels, theme: 'gitlab'
.nothing-here-block - else
= _("No labels created yet.") = render 'shared/empty_states/labels'
%template#js-badge-item-template
%li.label-link-item.js-priority-badge.inline.prepend-left-10
.label-badge.label-badge-blue Prioritized label
...@@ -6,17 +6,18 @@ ...@@ -6,17 +6,18 @@
- show_label_issues_link = show_label_issuables_link?(label, :issues, project: @project) - show_label_issues_link = show_label_issuables_link?(label, :issues, project: @project)
%li.label-list-item{ id: label_css_id, data: { id: label.id } } %li.label-list-item{ id: label_css_id, data: { id: label.id } }
= render "shared/label_row", label: label = render "shared/label_row", label: label, subject: subject
%ul.label-actions-list %ul.label-actions-list
%li.inline %li.inline
.label-badge.label-badge-gray= label.model_name.human.capitalize .label-badge.label-badge-gray= label.model_name.human.capitalize
- if can?(current_user, :admin_label, @project) - if can?(current_user, :admin_label, label)
%li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label), - if subject.is_a?(Project)
dom_id: dom_id(label), type: label.type } } %li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label),
%button.label-action.add-priority.btn.btn-transparent.has-tooltip{ title: 'Prioritize', type: 'button', :'data-placement' => 'top' } dom_id: dom_id(label), type: label.type } }
= icon('star-o') %button.label-action.add-priority.btn.btn-transparent.has-tooltip{ title: 'Prioritize', type: 'button', :'data-placement' => 'top' }
%button.label-action.remove-priority.btn.btn-transparent.has-tooltip{ title: 'Remove priority', type: 'button', :'data-placement' => 'top' } = icon('star-o')
= icon('star') %button.label-action.remove-priority.btn.btn-transparent.has-tooltip{ title: 'Remove priority', type: 'button', :'data-placement' => 'top' }
= icon('star')
%li.inline %li.inline
= link_to edit_label_path(label), class: 'btn btn-transparent label-action' do = link_to edit_label_path(label), class: 'btn btn-transparent label-action' do
= icon('pencil') = icon('pencil')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment