Commit b8a63b7c authored by Dylan Griffith's avatar Dylan Griffith

Hide elasticsearch namespaces and projects when too many

As part of our rollout for
https://gitlab.com/gitlab-org/gitlab/issues/33681 we will end up having
thousands of namespaces in the rollout and this admin UI would break so
it's safest to hide it.
parent 3d68f364
......@@ -55,6 +55,18 @@ module EE
objects.map { |g| { id: g.id, text: g.full_name } }
end
# The admin UI cannot handle so many namespaces so we just hide it. We
# assume people doing this are using automation anyway.
def elasticsearch_too_many_namespaces?
ElasticsearchIndexedNamespace.count > 50
end
# The admin UI cannot handle so many projects so we just hide it. We
# assume people doing this are using automation anyway.
def elasticsearch_too_many_projects?
ElasticsearchIndexedProject.count > 50
end
def elasticsearch_namespace_ids
ElasticsearchIndexedNamespace.target_ids.join(',')
end
......
......@@ -67,11 +67,17 @@
.form-group.js-limit-namespaces{ class: ('hidden' unless @application_setting.elasticsearch_limit_indexing) }
= f.label :elasticsearch_namespace_ids, _('Namespaces to index'), class: 'label-bold'
= f.text_field :elasticsearch_namespace_ids, class: 'js-elasticsearch-namespaces', value: elasticsearch_namespace_ids, data: { selected: elasticsearch_objects_options(@application_setting.elasticsearch_limited_namespaces(true)).to_json }
- if elasticsearch_too_many_namespaces?
%p= _('Too many namespaces enabled. You will need to manage them via the console or the API.')
- else
= f.text_field :elasticsearch_namespace_ids, class: 'js-elasticsearch-namespaces', value: elasticsearch_namespace_ids, data: { selected: elasticsearch_objects_options(@application_setting.elasticsearch_limited_namespaces(true)).to_json }
.form-group.js-limit-projects{ class: ('hidden' unless @application_setting.elasticsearch_limit_indexing) }
= f.label :elasticsearch_project_ids, _('Projects to index'), class: 'label-bold'
= f.text_field :elasticsearch_project_ids, class: 'js-elasticsearch-projects', value: elasticsearch_project_ids, data: { selected: elasticsearch_objects_options(@application_setting.elasticsearch_limited_projects(true)).to_json }
- if elasticsearch_too_many_projects?
%p= _('Too many projects enabled. You will need to manage them via the console or the API.')
- else
= f.text_field :elasticsearch_project_ids, class: 'js-elasticsearch-projects', value: elasticsearch_project_ids, data: { selected: elasticsearch_objects_options(@application_setting.elasticsearch_limited_projects(true)).to_json }
.sub-section
%h4= _('Elasticsearch AWS IAM credentials')
......
---
title: Hide elasticsearch namespaces and projects when too many in rollout
merge_request: 21225
author:
type: changed
......@@ -31,4 +31,56 @@ describe 'admin/application_settings/_elasticsearch_form' do
expect(page.find_field('Enter new AWS Secret Access Key').value).to be_blank
end
end
context 'when there are elasticsearch indexed namespaces' do
let(:application_setting) { build(:application_setting, elasticsearch_limit_indexing: true) }
before do
create(:elasticsearch_indexed_namespace)
create(:elasticsearch_indexed_namespace)
create(:elasticsearch_indexed_namespace)
end
it 'shows the input' do
render
expect(rendered).to have_field('application_setting[elasticsearch_namespace_ids]')
end
context 'when there are too many elasticsearch indexed namespaces' do
before do
create_list :elasticsearch_indexed_namespace, 60
end
it 'hides the input' do
render
expect(rendered).not_to have_field('application_setting[elasticsearch_namespace_ids]')
end
end
end
context 'when there are elasticsearch indexed projects' do
let(:application_setting) { build(:application_setting, elasticsearch_limit_indexing: true) }
before do
create(:elasticsearch_indexed_project)
create(:elasticsearch_indexed_project)
create(:elasticsearch_indexed_project)
end
it 'shows the input' do
render
expect(rendered).to have_field('application_setting[elasticsearch_project_ids]')
end
context 'when there are too many elasticsearch indexed projects' do
before do
create_list :elasticsearch_indexed_project, 60
end
it 'hides the input' do
render
expect(rendered).not_to have_field('application_setting[elasticsearch_project_ids]')
end
end
end
end
......@@ -18660,6 +18660,12 @@ msgstr ""
msgid "Too many changes to show."
msgstr ""
msgid "Too many namespaces enabled. You will need to manage them via the console or the API."
msgstr ""
msgid "Too many projects enabled. You will need to manage them via the console or the API."
msgstr ""
msgid "Topics"
msgstr ""
......
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