Commit 8db8c419 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '263440-remove-vue_sidebar_labels-feature-flag' into 'master'

Remove `vue_sidebar_labels` feature flag

See merge request gitlab-org/gitlab!45413
parents ea17265c 497f9eef
......@@ -4,7 +4,7 @@
import $ from 'jquery';
import { difference, isEqual, escape, sortBy, template, union } from 'lodash';
import { sprintf, s__, __ } from './locale';
import { sprintf, __ } from './locale';
import axios from './lib/utils/axios_utils';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import CreateLabelDropdown from './create_label';
......@@ -13,7 +13,6 @@ import ModalStore from './boards/stores/modal_store';
import boardsStore from './boards/stores/boards_store';
import { isScopedLabel } from '~/lib/utils/common_utils';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { fixTitle } from '~/tooltips';
export default class LabelsSelect {
constructor(els, options = {}) {
......@@ -44,7 +43,6 @@ export default class LabelsSelect {
const $block = $selectbox.closest('.block');
const $form = $dropdown.closest('form, .js-issuable-update');
const $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span');
const $sidebarLabelTooltip = $block.find('.js-sidebar-labels-tooltip');
const $value = $block.find('.value');
const $dropdownMenu = $dropdown.parent().find('.dropdown-menu');
// eslint-disable-next-line no-jquery/no-fade
......@@ -91,7 +89,6 @@ export default class LabelsSelect {
axios
.put(issueUpdateURL, data)
.then(({ data }) => {
let labelTooltipTitle;
let template;
// eslint-disable-next-line no-jquery/no-fade
$loading.fadeOut();
......@@ -151,24 +148,6 @@ export default class LabelsSelect {
$value.removeAttr('style').html(template);
$sidebarCollapsedValue.text(labelCount);
if (data.labels.length) {
let labelTitles = data.labels.map(label => label.title);
if (labelTitles.length > 5) {
labelTitles = labelTitles.slice(0, 5);
labelTitles.push(
sprintf(s__('Labels|and %{count} more'), { count: data.labels.length - 5 }),
);
}
labelTooltipTitle = labelTitles.join(', ');
} else {
labelTooltipTitle = __('Labels');
}
$sidebarLabelTooltip.attr('title', labelTooltipTitle);
fixTitle($sidebarLabelTooltip);
$('.has-tooltip', $value).tooltip({
container: 'body',
});
......
......@@ -44,7 +44,6 @@ class Projects::IssuesController < Projects::ApplicationController
push_frontend_feature_flag(:vue_issuable_sidebar, project.group)
push_frontend_feature_flag(:tribute_autocomplete, @project)
push_frontend_feature_flag(:vue_issuables_list, project)
push_frontend_feature_flag(:vue_sidebar_labels, @project, default_enabled: true)
end
before_action only: :show do
......
......@@ -49,12 +49,6 @@ module IssuablesHelper
"#{due_date.to_s(:medium)} (#{remaining_days_in_words(due_date, start_date)})"
end
def sidebar_label_filter_path(base_path, label_name)
query_params = { label_name: [label_name] }.to_query
"#{base_path}?#{query_params}"
end
def multi_label_name(current_labels, default_label)
return default_label if current_labels.blank?
......@@ -228,19 +222,6 @@ module IssuablesHelper
nil
end
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
if labels && labels.any?
label_names = first.collect { |label| label.fetch(:title) }
label_names << "and #{last.size} more" unless last.empty?
label_names.join(', ')
else
_("Labels")
end
end
def issuables_state_counter_text(issuable_type, state, display_count)
titles = {
opened: "Open"
......
......@@ -241,25 +241,6 @@ module LabelsHelper
}.merge(opts)
end
def sidebar_label_dropdown_data(issuable_type, issuable_sidebar)
label_dropdown_data(nil, {
default_label: "Labels",
field_name: "#{issuable_type}[label_names][]",
ability_name: issuable_type,
namespace_path: issuable_sidebar[:namespace_path],
project_path: issuable_sidebar[:project_path],
issue_update: issuable_sidebar[:issuable_json_path],
labels: issuable_sidebar[:project_labels_path],
display: 'static'
})
end
def label_from_hash(hash)
klass = hash[:group_id] ? GroupLabel : ProjectLabel
klass.new(hash.slice(:color, :description, :title, :group_id, :project_id))
end
def issuable_types
['issues', 'merge requests']
end
......
......@@ -103,7 +103,6 @@
.js-due-date-calendar
- if Feature.enabled?(:vue_sidebar_labels, @project, default_enabled: true)
.js-sidebar-labels{ data: { allow_label_create: issuable_sidebar.dig(:current_user, :can_admin_label).to_s,
allow_scoped_labels: issuable_sidebar[:scoped_labels_available].to_s,
can_edit: can_edit_issuable.to_s,
......@@ -115,37 +114,6 @@
project_issues_path: issuable_sidebar[:project_issuables_path],
project_path: @project.full_path,
selected_labels: issuable_sidebar[:labels].to_json } }
- else
- selected_labels = issuable_sidebar[:labels]
.block.labels{ data: { qa_selector: 'labels_block' } }
.sidebar-collapsed-icon.has-tooltip.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(selected_labels), data: { placement: "left", container: "body", boundary: 'viewport' } }
= sprite_icon('labels')
%span
= selected_labels.size
.title.hide-collapsed
= _('Labels')
= loading_icon(css_class: 'gl-vertical-align-text-bottom hidden block-loading')
- if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { qa_selector: "labels_edit_button", track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" }
.value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
- if selected_labels.any?
- selected_labels.each do |label_hash|
= render_label(label_from_hash(label_hash).present(issuable_subject: nil), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title]), dataset: { qa_selector: 'selected_label_content', qa_label_name: label_hash[:title] })
- else
%span.no-value
= _('None')
.selectbox.hide-collapsed
- selected_labels.each do |label|
= hidden_field_tag "#{issuable_type}[label_names][]", label[:id], id: nil
.dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{ type: "button", data: sidebar_label_dropdown_data(issuable_type, issuable_sidebar) }
%span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) }
= multi_label_name(selected_labels, "Labels")
= icon('chevron-down', 'aria-hidden': 'true')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable.dropdown-extended-height{ data: { qa_selector: "labels_dropdown_content"} }
= render partial: "shared/issuable/label_page_default"
- if issuable_sidebar.dig(:current_user, :can_admin_label)
= render partial: "shared/issuable/label_page_create"
= render_if_exists 'shared/issuable/sidebar_weight', issuable_sidebar: issuable_sidebar
......
---
name: vue_sidebar_labels
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41561
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/263440
group: group::project management
type: development
default_enabled: true
......@@ -58,12 +58,6 @@ module EE
}.merge(scoped_labels_fields, opts)
end
def sidebar_label_dropdown_data(issuable_type, issuable_sidebar)
super.merge({
scoped_labels: issuable_sidebar[:scoped_labels_available].to_s
})
end
def issuable_types
return super unless @group&.feature_available?(:epics)
......
......@@ -15181,9 +15181,6 @@ msgstr ""
msgid "Labels|Promoting %{labelTitle} will make it available for all projects inside %{groupName}. Existing project labels with the same title will be merged. If a group label with the same title exists, it will also be merged. This action cannot be reversed."
msgstr ""
msgid "Labels|and %{count} more"
msgstr ""
msgid "Language"
msgstr ""
......
<div class="block labels">
<div class="sidebar-collapsed-icon js-sidebar-labels-tooltip"></div>
<div class="title hide-collapsed">
<a class="edit-link float-right" href="#">
Edit
</a>
</div>
<div class="selectbox hide-collapsed" style="display: none;">
<div class="dropdown">
<button class="dropdown-menu-toggle js-label-select js-multiselect" data-ability-name="issue" data-field-name="issue[label_names][]" data-issue-update="/root/test/issues/2.json" data-labels="/root/test/labels.json" data-project-id="12" data-show-any="true" data-show-no="true" data-toggle="dropdown" type="button">
<span class="dropdown-toggle-text">
Label
</span>
<i class="fa fa-chevron-down"></i>
</button>
<div class="dropdown-menu dropdown-select dropdown-menu-paging dropdown-menu-labels dropdown-menu-selectable">
<div class="dropdown-page-one">
<div class="dropdown-content"></div>
<div class="dropdown-loading">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div>
</div>
</div>
</div>
</div>
/* eslint-disable no-new */
import $ from 'jquery';
import MockAdapter from 'axios-mock-adapter';
import { shuffle } from 'lodash';
import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select';
import 'select2';
import '~/api';
import '~/create_label';
import '~/users_select';
let saveLabelCount = 0;
let mock;
function testLabelClicks(labelOrder, done) {
$('.edit-link')
.get(0)
.click();
jest.runOnlyPendingTimers();
setImmediate(() => {
const labelsInDropdown = $('.dropdown-content a');
expect(labelsInDropdown.length).toBe(10);
const arrayOfLabels = labelsInDropdown.get();
const randomArrayOfLabels = shuffle(arrayOfLabels);
randomArrayOfLabels.forEach((label, i) => {
if (i < saveLabelCount) {
$(label).click();
}
});
$('.edit-link')
.get(0)
.click();
setImmediate(() => {
expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe(labelOrder);
done();
});
});
}
describe('Issue dropdown sidebar', () => {
preloadFixtures('static/issue_sidebar_label.html');
beforeEach(() => {
loadFixtures('static/issue_sidebar_label.html');
mock = new MockAdapter(axios);
new IssuableContext('{"id":1,"name":"Administrator","username":"root"}');
new LabelsSelect();
mock.onGet('/root/test/labels.json').reply(() => {
const labels = Array(10)
.fill()
.map((_val, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
}));
return [200, labels];
});
mock.onPut('/root/test/issues/2.json').reply(() => {
const labels = Array(saveLabelCount)
.fill()
.map((_val, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
}));
return [200, { labels }];
});
});
afterEach(() => {
mock.restore();
});
it('changes collapsed tooltip when changing labels when less than 5', done => {
saveLabelCount = 5;
testLabelClicks('test 0, test 1, test 2, test 3, test 4', done);
});
it('changes collapsed tooltip when changing labels when more than 5', done => {
saveLabelCount = 6;
testLabelClicks('test 0, test 1, test 2, test 3, test 4, and 1 more', done);
});
});
......@@ -44,23 +44,6 @@ RSpec.describe IssuablesHelper do
end
end
describe '#issuable_labels_tooltip' do
let(:label_entity) { LabelEntity.represent(label).as_json }
let(:label2_entity) { LabelEntity.represent(label2).as_json }
it 'returns label text with no labels' do
expect(issuable_labels_tooltip([])).to eq(_('Labels'))
end
it 'returns label text with labels within max limit' do
expect(issuable_labels_tooltip([label_entity])).to eq(label[:title])
end
it 'returns label text with labels exceeding max limit' do
expect(issuable_labels_tooltip([label_entity, label2_entity], limit: 1)).to eq("#{label[:title]}, and 1 more")
end
end
describe '#issuables_state_counter_text' do
let(:user) { create(:user) }
......
......@@ -244,26 +244,6 @@ RSpec.describe LabelsHelper do
end
end
describe 'label_from_hash' do
it 'builds a group label with whitelisted attributes' do
label = label_from_hash({ title: 'foo', color: 'bar', id: 1, group_id: 1 })
expect(label).to be_a(GroupLabel)
expect(label.id).to be_nil
expect(label.title).to eq('foo')
expect(label.color).to eq('bar')
end
it 'builds a project label with whitelisted attributes' do
label = label_from_hash({ title: 'foo', color: 'bar', id: 1, project_id: 1 })
expect(label).to be_a(ProjectLabel)
expect(label.id).to be_nil
expect(label.title).to eq('foo')
expect(label.color).to eq('bar')
end
end
describe '#label_status_tooltip' do
let(:status) { 'unsubscribed'.inquiry }
......
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