Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-06-30 21:09:47 +00:00
parent 79040c6178
commit b1c4066c6b
12 changed files with 114 additions and 40 deletions

View File

@ -20,18 +20,22 @@ export const toNounSeriesText = items => {
if (items.length === 0) { if (items.length === 0) {
return ''; return '';
} else if (items.length === 1) { } else if (items.length === 1) {
return items[0]; return sprintf(s__(`nounSeries|%{item}`), { item: items[0] }, false);
} else if (items.length === 2) { } else if (items.length === 2) {
return sprintf(s__('nounSeries|%{firstItem} and %{lastItem}'), { return sprintf(
firstItem: items[0], s__('nounSeries|%{firstItem} and %{lastItem}'),
lastItem: items[1], {
}); firstItem: items[0],
lastItem: items[1],
},
false,
);
} }
return items.reduce((item, nextItem, idx) => return items.reduce((item, nextItem, idx) =>
idx === items.length - 1 idx === items.length - 1
? sprintf(s__('nounSeries|%{item}, and %{lastItem}'), { item, lastItem: nextItem }) ? sprintf(s__('nounSeries|%{item}, and %{lastItem}'), { item, lastItem: nextItem }, false)
: sprintf(s__('nounSeries|%{item}, %{nextItem}'), { item, nextItem }), : sprintf(s__('nounSeries|%{item}, %{nextItem}'), { item, nextItem }, false),
); );
}; };

View File

@ -19,6 +19,9 @@
# personal: boolean # personal: boolean
# search: string # search: string
# non_archived: boolean # non_archived: boolean
# with_issues_enabled: boolean
# with_merge_requests_enabled: boolean
# min_access_level: int
# #
class GroupProjectsFinder < ProjectsFinder class GroupProjectsFinder < ProjectsFinder
DEFAULT_PROJECTS_LIMIT = 100 DEFAULT_PROJECTS_LIMIT = 100
@ -42,6 +45,12 @@ class GroupProjectsFinder < ProjectsFinder
private private
def filter_projects(collection)
projects = super
projects = by_feature_availability(projects)
projects
end
def limit(collection) def limit(collection)
limit = options[:limit] limit = options[:limit]
@ -49,35 +58,37 @@ class GroupProjectsFinder < ProjectsFinder
end end
def init_collection def init_collection
projects = if current_user projects =
collection_with_user if only_shared?
else [shared_projects]
collection_without_user elsif only_owned?
end [owned_projects]
else
[owned_projects, shared_projects]
end
projects.map! do |project_relation|
filter_by_visibility(project_relation)
end
union(projects) union(projects)
end end
def collection_with_user def by_feature_availability(projects)
if only_shared? projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled].present?
[shared_projects.public_or_visible_to_user(current_user)] projects = projects.with_merge_requests_available_for_user(current_user) if params[:with_merge_requests_enabled].present?
elsif only_owned? projects
[owned_projects.public_or_visible_to_user(current_user)]
else
[
owned_projects.public_or_visible_to_user(current_user),
shared_projects.public_or_visible_to_user(current_user)
]
end
end end
def collection_without_user def filter_by_visibility(relation)
if only_shared? if current_user
[shared_projects.public_only] if min_access_level?
elsif only_owned? relation.visible_to_user_and_access_level(current_user, params[:min_access_level])
[owned_projects.public_only] else
relation.public_or_visible_to_user(current_user)
end
else else
[shared_projects.public_only, owned_projects.public_only] relation.public_only
end end
end end

View File

@ -1,7 +1,7 @@
= form_tag project_compare_index_path(@project), method: :post, class: 'form-inline js-requires-input js-signature-container', data: { 'signatures-path' => signatures_namespace_project_compare_index_path } do = form_tag project_compare_index_path(@project), method: :post, class: 'form-inline js-requires-input js-signature-container', data: { 'signatures-path' => signatures_namespace_project_compare_index_path } do
- if params[:to] && params[:from] - if params[:to] && params[:from]
.compare-switch-container .compare-switch-container
= link_to icon('exchange'), { from: params[:to], to: params[:from] }, class: 'commits-compare-switch has-tooltip btn btn-white', title: 'Swap revisions' = link_to sprite_icon('substitute'), { from: params[:to], to: params[:from] }, class: 'commits-compare-switch has-tooltip btn btn-white', title: 'Swap revisions'
.form-group.dropdown.compare-form-group.to.js-compare-to-dropdown .form-group.dropdown.compare-form-group.to.js-compare-to-dropdown
.input-group.inline-input-group .input-group.inline-input-group
%span.input-group-prepend %span.input-group-prepend

View File

@ -0,0 +1,5 @@
---
title: Move filter code into finder
merge_request: 34470
author: Ravishankar
type: other

View File

@ -0,0 +1,5 @@
---
title: Replace FA exchange icon with GitLab SVG
merge_request: 35634
author:
type: changed

View File

@ -23,6 +23,9 @@ future GitLab releases.**
You can add a command to your `.gitlab-ci.yml` file to You can add a command to your `.gitlab-ci.yml` file to
[output the values of all variables available for a job](README.md#list-all-environment-variables). [output the values of all variables available for a job](README.md#list-all-environment-variables).
Kubernetes-specific environment variables are detailed in the
[Kubernetes deployment variables](../../user/project/clusters/index.md#deployment-variables) section.
| Variable | GitLab | Runner | Description | | Variable | GitLab | Runner | Description |
|-----------------------------------------------|--------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------------------------------------|--------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `CHAT_CHANNEL` | 10.6 | all | Source chat channel which triggered the [ChatOps](../chatops/README.md) command | | `CHAT_CHANNEL` | 10.6 | all | Source chat channel which triggered the [ChatOps](../chatops/README.md) command |

View File

@ -76,9 +76,6 @@ module API
params: project_finder_params, params: project_finder_params,
options: finder_options options: finder_options
).execute ).execute
projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
projects = projects.visible_to_user_and_access_level(current_user, params[:min_access_level]) if params[:min_access_level]
projects = reorder_projects(projects) projects = reorder_projects(projects)
paginate(projects) paginate(projects)
end end

View File

@ -528,6 +528,8 @@ module API
def project_finder_params_ce def project_finder_params_ce
finder_params = project_finder_params_visibility_ce finder_params = project_finder_params_visibility_ce
finder_params[:with_issues_enabled] = true if params[:with_issues_enabled].present?
finder_params[:with_merge_requests_enabled] = true if params[:with_merge_requests_enabled].present?
finder_params[:without_deleted] = true finder_params[:without_deleted] = true
finder_params[:search] = params[:search] if params[:search] finder_params[:search] = params[:search] if params[:search]
finder_params[:search_namespaces] = true if params[:search_namespaces].present? finder_params[:search_namespaces] = true if params[:search_namespaces].present?

View File

@ -27740,6 +27740,9 @@ msgstr ""
msgid "nounSeries|%{firstItem} and %{lastItem}" msgid "nounSeries|%{firstItem} and %{lastItem}"
msgstr "" msgstr ""
msgid "nounSeries|%{item}"
msgstr ""
msgid "nounSeries|%{item}, %{nextItem}" msgid "nounSeries|%{item}, %{nextItem}"
msgstr "" msgstr ""

View File

@ -67,7 +67,7 @@ module QA
# attachment option should be an absolute path # attachment option should be an absolute path
def comment(text, attachment: nil, filter: :all_activities) def comment(text, attachment: nil, filter: :all_activities)
method("select_#{filter}_filter").call method("select_#{filter}_filter").call
fill_element :comment_input, text fill_element :comment_input, "#{text}\n"
unless attachment.nil? unless attachment.nil?
QA::Page::Component::Dropzone.new(self, '.new-note') QA::Page::Component::Dropzone.new(self, '.new-note')

View File

@ -46,6 +46,18 @@ RSpec.describe GroupProjectsFinder do
context 'without subgroups projects' do context 'without subgroups projects' do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, private_project, public_project]) } it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, private_project, public_project]) }
end end
context "with min access level" do
let!(:shared_project_4) { create(:project, :internal, path: '8') }
before do
shared_project_4.project_group_links.create(group_access: Gitlab::Access::REPORTER, group: group)
end
let(:params) { { min_access_level: Gitlab::Access::MAINTAINER } }
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, private_project, public_project]) }
end
end end
end end
@ -171,6 +183,38 @@ RSpec.describe GroupProjectsFinder do
end end
end end
describe 'feature availability' do
let!(:project_with_issues_disabled) { create(:project, :issues_disabled, :internal, path: '9') }
let!(:project_with_merge_request_disabled) { create(:project, :merge_requests_disabled, :internal, path: '10') }
before do
project_with_issues_disabled.project_group_links.create!(group_access: Gitlab::Access::REPORTER, group: group)
project_with_merge_request_disabled.project_group_links.create!(group_access: Gitlab::Access::REPORTER, group: group)
end
context 'without issues and merge request enabled' do
it { is_expected.to match_array([public_project, shared_project_1, shared_project_3, project_with_issues_disabled, project_with_merge_request_disabled]) }
end
context 'with issues enabled' do
let(:params) { { with_issues_enabled: true } }
it { is_expected.to match_array([public_project, shared_project_1, shared_project_3, project_with_merge_request_disabled]) }
end
context 'with merge request enabled' do
let(:params) { { with_merge_requests_enabled: true } }
it { is_expected.to match_array([public_project, shared_project_1, shared_project_3, project_with_issues_disabled]) }
end
context 'with issues and merge request enabled' do
let(:params) { { with_merge_requests_enabled: true, with_issues_enabled: true } }
it { is_expected.to match_array([public_project, shared_project_1, shared_project_3]) }
end
end
describe 'limiting' do describe 'limiting' do
context 'without limiting' do context 'without limiting' do
it 'returns all projects' do it 'returns all projects' do

View File

@ -7,27 +7,27 @@ describe('utils/grammar', () => {
}); });
it('with single item returns item', () => { it('with single item returns item', () => {
const items = ['Lorem Ipsum']; const items = ['Lorem & Ipsum'];
expect(grammar.toNounSeriesText(items)).toBe(items[0]); expect(grammar.toNounSeriesText(items)).toBe(items[0]);
}); });
it('with 2 items returns item1 and item2', () => { it('with 2 items returns item1 and item2', () => {
const items = ['Dolar', 'Sit Amit']; const items = ['Dolar', 'Sit & Amit'];
expect(grammar.toNounSeriesText(items)).toBe(`${items[0]} and ${items[1]}`); expect(grammar.toNounSeriesText(items)).toBe(`${items[0]} and ${items[1]}`);
}); });
it('with 3 items returns comma separated series', () => { it('with 3 items returns comma separated series', () => {
const items = ['Lorem', 'Ipsum', 'dolar']; const items = ['Lorem', 'Ipsum', 'Sit & Amit'];
const expected = 'Lorem, Ipsum, and dolar'; const expected = 'Lorem, Ipsum, and Sit & Amit';
expect(grammar.toNounSeriesText(items)).toBe(expected); expect(grammar.toNounSeriesText(items)).toBe(expected);
}); });
it('with 6 items returns comma separated series', () => { it('with 6 items returns comma separated series', () => {
const items = ['Lorem', 'ipsum', 'dolar', 'sit', 'amit', 'consectetur']; const items = ['Lorem', 'ipsum', 'dolar', 'sit', 'amit', 'consectetur & adipiscing'];
const expected = 'Lorem, ipsum, dolar, sit, amit, and consectetur'; const expected = 'Lorem, ipsum, dolar, sit, amit, and consectetur & adipiscing';
expect(grammar.toNounSeriesText(items)).toBe(expected); expect(grammar.toNounSeriesText(items)).toBe(expected);
}); });