Commit 7e36fa39 authored by Luke Bennett's avatar Luke Bennett

FE review changes

parent 9b9cdc98
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import flash from './flash'; import flash from './flash';
import { __ } from './locale';
const tooltipTitles = {
group: __('Unsubscribe at group level'),
project: __('Unsubscribe at project level'),
};
export default class GroupLabelSubscription { export default class GroupLabelSubscription {
constructor(container) { constructor(container) {
...@@ -48,11 +53,11 @@ export default class GroupLabelSubscription { ...@@ -48,11 +53,11 @@ export default class GroupLabelSubscription {
static setNewTooltip($button) { static setNewTooltip($button) {
if (!$button.hasClass('js-subscribe-button')) return; if (!$button.hasClass('js-subscribe-button')) return;
const type = $button.hasClass('js-group-level') ? 'group' : 'project'; const type = $button.hasClass('js-group-level') ? 'group' : 'project';
const title = `Unsubscribe at ${type} level`; const newTitle = tooltipTitles[type];
const $unsubscribeButton = $('.js-unsubscribe-button', $button.closest('.label-actions-list'));
$unsubscribeButton.tooltip('hide').attr('title', title).tooltip('_fixTitle'); $('.js-unsubscribe-button', $button.closest('.label-actions-list'))
.tooltip('hide').attr('title', newTitle).tooltip('_fixTitle');
} }
} }
...@@ -13,7 +13,7 @@ export default class LabelManager { ...@@ -13,7 +13,7 @@ export default class LabelManager {
this.otherLabels = otherLabels || $('.js-other-labels'); this.otherLabels = otherLabels || $('.js-other-labels');
this.errorMessage = 'Unable to update label prioritization at this time'; this.errorMessage = 'Unable to update label prioritization at this time';
this.emptyState = document.querySelector('#js-priority-labels-empty-state'); this.emptyState = document.querySelector('#js-priority-labels-empty-state');
this.$badgeItemTemplate = $(document.getElementById('js-badge-item-template').innerHTML); this.$badgeItemTemplate = $('#js-badge-item-template');
this.sortable = Sortable.create(this.prioritizedLabels.get(0), { this.sortable = Sortable.create(this.prioritizedLabels.get(0), {
filter: '.empty-message', filter: '.empty-message',
forceFallback: true, forceFallback: true,
...@@ -97,7 +97,7 @@ export default class LabelManager { ...@@ -97,7 +97,7 @@ export default class LabelManager {
if (action === 'remove') { if (action === 'remove') {
$('.js-priority-badge', $label).remove(); $('.js-priority-badge', $label).remove();
} else { } else {
$('.label-links', $label).append(this.$badgeItemTemplate.clone()); $('.label-links', $label).append(this.$badgeItemTemplate.clone().html());
} }
} }
......
...@@ -3,6 +3,17 @@ import { __ } from './locale'; ...@@ -3,6 +3,17 @@ import { __ } from './locale';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import flash from './flash'; import flash from './flash';
const tooltipTitles = {
group: {
subscribed: __('Unsubscribe at group level'),
unsubscribed: __('Subscribe at group level'),
},
project: {
subscribed: __('Unsubscribe at project level'),
unsubscribed: __('Subscribe at project level'),
},
};
export default class ProjectLabelSubscription { export default class ProjectLabelSubscription {
constructor(container) { constructor(container) {
this.$container = $(container); this.$container = $(container);
...@@ -48,11 +59,10 @@ export default class ProjectLabelSubscription { ...@@ -48,11 +59,10 @@ export default class ProjectLabelSubscription {
}).catch(() => flash(__('There was an error subscribing to this label.'))); }).catch(() => flash(__('There was an error subscribing to this label.')));
} }
static setNewTitle($button, originalTitle, newStatus, newAction) { static setNewTitle($button, originalTitle, newStatus) {
const newStatusVerb = newStatus.slice(0, -1); const type = /group/.test(originalTitle) ? 'group' : 'project';
const actionRegexp = new RegExp(newStatusVerb, 'i'); const newTitle = tooltipTitles[type][newStatus];
const newTitle = originalTitle.replace(actionRegexp, newAction);
$button.tooltip('hide').attr('data-original-title', newTitle).tooltip('_fixTitle'); $button.tooltip('hide').attr('title', newTitle).tooltip('_fixTitle');
} }
} }
...@@ -464,7 +464,6 @@ img.emoji { ...@@ -464,7 +464,6 @@ img.emoji {
.prepend-left-5 { margin-left: 5px; } .prepend-left-5 { margin-left: 5px; }
.prepend-left-8 { margin-left: 8px; } .prepend-left-8 { margin-left: 8px; }
.prepend-left-10 { margin-left: 10px; } .prepend-left-10 { margin-left: 10px; }
.prepend-left-15 { margin-left: 15px; }
.prepend-left-default { margin-left: $gl-padding; } .prepend-left-default { margin-left: $gl-padding; }
.prepend-left-20 { margin-left: 20px; } .prepend-left-20 { margin-left: 20px; }
.append-right-5 { margin-right: 5px; } .append-right-5 { margin-right: 5px; }
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
margin-bottom: 5px; margin-bottom: 5px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 11px 10px 11px $gl-padding; padding: 8px 8px 8px $gl-padding;
border-radius: $border-radius-default; border-radius: $border-radius-default;
&.sortable-ghost { &.sortable-ghost {
...@@ -270,7 +270,6 @@ ...@@ -270,7 +270,6 @@
.content-list &::before, .content-list &::before,
.content-list &::after { .content-list &::after {
content: none; content: none;
display: block;
} }
.label-name { .label-name {
...@@ -284,12 +283,6 @@ ...@@ -284,12 +283,6 @@
} }
} }
.label-type {
display: block;
margin-bottom: 10px;
margin-left: 50px;
}
.label-description { .label-description {
flex-grow: 1; flex-grow: 1;
...@@ -302,7 +295,7 @@ ...@@ -302,7 +295,7 @@
padding: 4px $grid-size; padding: 4px $grid-size;
font-size: $label-font-size; font-size: $label-font-size;
position: relative; position: relative;
top: ($grid-size / 2); top: $gl-padding-4;
} }
.label-action { .label-action {
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
- 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_group_label_path(@group), class: "btn btn-new" do = link_to _('New label'), new_group_label_path(@group), class: "btn btn-new"
= _('New label')
- if @labels.exists? - if @labels.exists?
#promote-label-modal #promote-label-modal
...@@ -32,4 +31,4 @@ ...@@ -32,4 +31,4 @@
%template#js-badge-item-template %template#js-badge-item-template
%li.label-link-item.js-priority-badge.inline.prepend-left-10 %li.label-link-item.js-priority-badge.inline.prepend-left-10
.label-badge.label-badge-blue Prioritized label .label-badge.label-badge-blue= _('Prioritized label')
...@@ -6,24 +6,23 @@ ...@@ -6,24 +6,23 @@
- 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_project_label_path(@project), class: "btn btn-new" do = link_to _('New label'), new_project_label_path(@project), class: "btn btn-new"
New label
- if @labels.exists? || @prioritized_labels.exists? - if @labels.exists? || @prioritized_labels.exists?
#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 - if can_admin_label
Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging. = _('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 .labels-container.prepend-top-5
- if can_admin_label - if can_admin_label
-# 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-0 Prioritized Labels %h5.prepend-top-0= _('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?}" }
= render 'shared/empty_states/priority_labels' = render 'shared/empty_states/priority_labels'
...@@ -33,7 +32,7 @@ ...@@ -33,7 +32,7 @@
- if @labels.present? - if @labels.present?
.other-labels .other-labels
- if can_admin_label - if can_admin_label
%h5{ class: ('hide' if hide) } Other Labels %h5{ class: ('hide' if hide) }= _('Other Labels')
.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'
...@@ -42,4 +41,4 @@ ...@@ -42,4 +41,4 @@
%template#js-badge-item-template %template#js-badge-item-template
%li.label-link-item.js-priority-badge.inline.prepend-left-10 %li.label-link-item.js-priority-badge.inline.prepend-left-10
.label-badge.label-badge-blue Prioritized label .label-badge.label-badge-blue= _('Prioritized label')
...@@ -11,22 +11,22 @@ ...@@ -11,22 +11,22 @@
%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, subject: subject, force_priority: force_priority = render "shared/label_row", label: label, subject: subject, force_priority: force_priority
%ul.label-actions-list %ul.label-actions-list
- if controller.is_a?(Projects::LabelsController) - if @project
%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, @project)
%li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label), %li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label),
dom_id: dom_id(label), type: label.type } } dom_id: dom_id(label), type: label.type } }
%button.label-action.add-priority.btn.btn-transparent.has-tooltip{ title: _('Prioritize'), type: 'button', :'data-placement' => 'top' } %button.label-action.add-priority.btn.btn-transparent.has-tooltip{ title: _('Prioritize'), type: 'button', data: { placement: 'top' }, aria_label: _('Prioritize label') }
= sprite_icon('star-o') = sprite_icon('star-o')
%button.label-action.remove-priority.btn.btn-transparent.has-tooltip{ title: _('Remove priority'), type: 'button', :'data-placement' => 'top' } %button.label-action.remove-priority.btn.btn-transparent.has-tooltip{ title: _('Remove priority'), type: 'button', data: { placement: 'top' }, aria_label: _('Deprioritize label') }
= sprite_icon('star') = sprite_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', aria_label: 'Edit label' do
= sprite_icon('pencil') = sprite_icon('pencil')
%li.inline %li.inline
.dropdown .dropdown
%button{ type: 'button', class: 'btn btn-transparent js-label-options-dropdown label-action', data: { toggle: 'dropdown' } } %button{ type: 'button', class: 'btn btn-transparent js-label-options-dropdown label-action', data: { toggle: 'dropdown' }, aria_label: _('Label actions dropdown') }
= sprite_icon('ellipsis_v') = sprite_icon('ellipsis_v')
.dropdown-menu.dropdown-open-left .dropdown-menu.dropdown-open-left
%ul %ul
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
= _('Promote to group label') = _('Promote to group label')
%li %li
%span{ data: { toggle: 'modal', target: "#modal-delete-label-#{label.id}" } } %span{ data: { toggle: 'modal', target: "#modal-delete-label-#{label.id}" } }
= button_tag 'Delete', type: 'button', class: 'text-danger remove-row' %button.text-danger.remove-row{ type: 'button' }= _('Delete')
- if current_user - if current_user
%li.inline.label-subscription %li.inline.label-subscription
- if can_subscribe_to_label_in_different_levels?(label) - if can_subscribe_to_label_in_different_levels?(label)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.label-name .label-name
= link_to_label(label, subject: @project, tooltip: false) = link_to_label(label, subject: @project, tooltip: false)
.label-description .label-description
.append-right-15.prepend-left-15 .append-right-default.prepend-left-default
- if label.description.present? - if label.description.present?
.description-text.append-bottom-10 .description-text.append-bottom-10
= markdown_field(label, :description) = markdown_field(label, :description)
......
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