Commit ba8ec598 authored by Changzheng Liu's avatar Changzheng Liu Committed by Patrick Bajao

Move Advanced Search Admin Settings to Top Level

parent 1c326df5
......@@ -104,7 +104,6 @@
= f.submit _('Save changes'), class: "gl-button btn btn-success"
= render_if_exists 'admin/application_settings/maintenance_mode_settings_form'
= render_if_exists 'admin/application_settings/elasticsearch_form'
= render 'admin/application_settings/gitpod'
= render 'admin/application_settings/kroki'
= render 'admin/application_settings/plantuml'
......
......@@ -9,7 +9,7 @@
= sprite_icon('close', css_class: 'gl-icon')
.gl-alert-body
%h4.gl-alert-title= s_('AdminSettings|Some settings have moved')
= html_escape_once(s_('AdminSettings|Elasticsearch, PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings > General.')).html_safe
= html_escape_once(s_('AdminSettings|PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings > General.')).html_safe
.gl-alert-actions
= link_to s_('AdminSettings|Go to General Settings'), general_admin_application_settings_path, class: 'btn gl-alert-action btn-info new-gl-button'
......
......@@ -260,6 +260,9 @@
= link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span
= _('General')
= render_if_exists 'layouts/nav/sidebar/advanced_search', class: 'qa-admin-settings-advanced-search'
- if instance_level_integrations?
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
......
......@@ -175,8 +175,7 @@ instances](#indexing-large-instances) below.
To enable Advanced Search, you need to have admin access to GitLab:
1. Navigate to **Admin Area**, then **Settings > General**
and expand the **Advanced Search** section.
1. Navigate to **Admin Area**, then **Settings > Advanced Search**.
NOTE:
To see the Advanced Search section, you need an active Starter
......@@ -186,7 +185,7 @@ To enable Advanced Search, you need to have admin access to GitLab:
your Elasticsearch cluster. Do not enable **Search with Elasticsearch enabled**
yet.
1. Now enable **Elasticsearch indexing** in **Admin Area > Settings >
General > Advanced Search** and click **Save changes**. This will create
Advanced Search** and click **Save changes**. This will create
an empty index if one does not already exist.
1. Click **Index all projects**.
1. Click **Check progress** in the confirmation message to see the status of
......@@ -202,7 +201,7 @@ To enable Advanced Search, you need to have admin access to GitLab:
```
1. After the indexing has completed, enable **Search with Elasticsearch enabled** in
**Admin Area > Settings > General > Advanced Search** and click **Save
**Admin Area > Settings > Advanced Search** and click **Save
changes**.
NOTE:
......@@ -265,8 +264,8 @@ You can improve the language support for Chinese and Japanese languages by utili
To enable language(s) support:
1. Install the desired plugin(s), please refer to [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/plugins/7.9/installation.html) for plugins installation instructions. The plugin(s) must be installed on every node in the cluster, and each node must be restarted after installation. For a list of plugins, see the table later in this section.
1. Navigate to the **Admin Area**, then **Settings > General**..
1. Expand the **Advanced Search** section and locate **Custom analyzers: language support**.
1. Navigate to the **Admin Area**, then **Settings > Advanced Search**..
1. Locate **Custom analyzers: language support**.
1. Enable plugin(s) support for **Indexing**.
1. Click **Save changes** for the changes to take effect.
1. Trigger [Zero downtime reindexing](#zero-downtime-reindexing) or reindex everything from scratch to create a new index with updated mappings.
......@@ -285,9 +284,8 @@ For guidance on what to install, see the following Elasticsearch language plugin
To disable the Elasticsearch integration:
1. Navigate to the **Admin Area**, then **Settings > General**.
1. Expand the **Advanced Search** section and uncheck **Elasticsearch indexing**
and **Search with Elasticsearch enabled**.
1. Navigate to the **Admin Area**, then **Settings > Advanced Search**.
1. Uncheck **Elasticsearch indexing** and **Search with Elasticsearch enabled**.
1. Click **Save changes** for the changes to take effect.
1. (Optional) Delete the existing indexes:
......@@ -315,7 +313,7 @@ used by the GitLab Advanced Search integration.
### Pause the indexing
In the **Admin Area > Settings > General > Advanced Search** section, select the
In the **Admin Area > Settings > Advanced Search** section, select the
**Pause Elasticsearch Indexing** setting, and then save your change.
With this, all updates that should happen on your Elasticsearch index will be
buffered and caught up once unpaused.
......@@ -332,7 +330,7 @@ This process involves several shell commands and curl invocations, so a good
initial setup will help for later:
```shell
# You can find this value under Admin Area > Settings > General > Advanced Search > URL
# You can find this value under Admin Area > Settings > Advanced Search > URL
export CLUSTER_URL="http://localhost:9200"
export PRIMARY_INDEX="gitlab-production"
export SECONDARY_INDEX="gitlab-production-$(date +%s)"
......@@ -433,14 +431,14 @@ To trigger the re-index from `primary` index:
1. Unpause the indexing
Under **Admin Area > Settings > General > Advanced Search**, uncheck the **Pause Elasticsearch Indexing** setting and save.
Under **Admin Area > Settings > Advanced Search**, uncheck the **Pause Elasticsearch Indexing** setting and save.
### Trigger the reindex via the Advanced Search administration
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34069) in [GitLab Starter](https://about.gitlab.com/pricing/) 13.2.
> - A scheduled index deletion and the ability to cancel it was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38914) in GitLab Starter 13.3.
Under **Admin Area > Settings > General > Advanced Search > Elasticsearch zero-downtime reindexing**, click on **Trigger cluster reindexing**.
Under **Admin Area > Settings > Advanced Search > Elasticsearch zero-downtime reindexing**, click on **Trigger cluster reindexing**.
Reindexing can be a lengthy process depending on the size of your Elasticsearch cluster.
......@@ -463,7 +461,7 @@ Sometimes, you might want to abandon the unfinished reindex job and unpause the
bundle exec rake gitlab:elastic:mark_reindex_failed RAILS_ENV=production
```
1. Uncheck the "Pause Elasticsearch indexing" checkbox in **Admin Area > Settings > General > Advanced Search**.
1. Uncheck the "Pause Elasticsearch indexing" checkbox in **Admin Area > Settings > Advanced Search**.
## Background migrations
......@@ -823,7 +821,7 @@ There are a couple of ways to achieve that:
This is always correctly identifying whether the current project/namespace
being searched is using Elasticsearch.
- From the admin area under **Settings > General > Advanced Search** check that the
- From the admin area under **Settings > Advanced Search** check that the
Advanced Search settings are checked.
Those same settings there can be obtained from the Rails console if necessary:
......
......@@ -59,6 +59,6 @@ class Admin::ElasticsearchController < Admin::ApplicationController
private
def redirect_path
general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
end
......@@ -7,17 +7,18 @@ module EE
extend ActiveSupport::Concern
prepended do
before_action :elasticsearch_reindexing_task, only: [:general]
before_action :elasticsearch_reindexing_task, only: [:advanced_search]
feature_category :provision, [:seat_link_payload]
feature_category :source_code_management, [:templates]
feature_category :global_search, [:advanced_search]
def elasticsearch_reindexing_task
@elasticsearch_reindexing_task = Elastic::ReindexingTask.last
end
end
EE_VALID_SETTING_PANELS = %w(templates).freeze
EE_VALID_SETTING_PANELS = %w(advanced_search templates).freeze
EE_VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? }
......
......@@ -3,21 +3,18 @@
- recreate_index_url = help_page_url('integration/elasticsearch.md')
- recreate_index_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: recreate_index_url }
- recreate_index_text = _("Changes won't take place until the index is %{link_start}recreated%{link_end}.").html_safe % { link_start: recreate_index_link_start, link_end: '</a>'.html_safe }
- expanded = integration_expanded?('elasticsearch_')
- elasticsearch_available = Gitlab::Elastic::Helper.default.client.ping
%section.settings.as-elasticsearch.no-animate#js-elasticsearch-settings{ class: ('expanded' if expanded), data: { qa_selector: 'elasticsearch_tab' } }
%section.settings.expanded.as-elasticsearch.no-animate#js-elasticsearch-settings{ data: { qa_selector: 'elasticsearch_tab' } }
.settings-header
%h4
= _('Advanced Search')
%button.btn.gl-button.js-settings-toggle{ type: 'button' }
= expanded ? 'Collapse' : 'Expand'
%p
= _('Advanced Search with Elasticsearch')
.settings-content
= form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-elasticsearch-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) if expanded
= form_for @application_setting, url: advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
%fieldset
.sub-section
......
- breadcrumb_title _("Advanced Search")
- page_title _("Advanced Search")
- @content_class = "limit-container-width" unless fluid_layout
= render_if_exists 'admin/application_settings/elasticsearch_form'
= feature_entry(_('Advanced Search'),
href: general_admin_application_settings_path(anchor: 'js-elasticsearch-settings'),
href: advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings'),
doc_href: help_page_path('integration/elasticsearch'),
enabled: Gitlab::CurrentSettings.elasticsearch_search?)
......
- return unless License.feature_available?(:elastic_search)
= nav_link(path: 'application_settings#advanced_search') do
= link_to advanced_search_admin_application_settings_path, title: _('Advanced Search'), class: 'qa-admin-settings-advanced-search' do
%span
= _('Advanced Search')
---
title: Move Advanced Search Admin Settings to Top Level
merge_request: 51026
author:
type: changed
......@@ -35,7 +35,7 @@ namespace :admin do
# using `only: []` to keep duplicate routes from being created
resource :application_settings, only: [] do
get :seat_link_payload
match :templates, via: [:get, :patch]
match :templates, :advanced_search, via: [:get, :patch]
get :geo, to: "geo/settings#show"
end
......
......@@ -11,25 +11,6 @@ RSpec.describe Admin::ApplicationSettingsController do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
describe 'GET #general' do
before do
sign_in(admin)
end
context 'zero-downtime elasticsearch reindexing' do
render_views
let!(:task) { create(:elastic_reindexing_task) }
it 'assigns elasticsearch reindexing task' do
get :general
expect(assigns(:elasticsearch_reindexing_task)).to eq(task)
expect(response.body).to include("Reindexing Status: #{task.state}")
end
end
end
describe 'PUT #update' do
before do
sign_in(admin)
......@@ -38,13 +19,6 @@ RSpec.describe Admin::ApplicationSettingsController do
it 'updates the EE specific application settings' do
settings = {
help_text: 'help_text',
elasticsearch_url: 'http://my-elastic.search:9200',
elasticsearch_indexing: false,
elasticsearch_aws: true,
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: 'elasticsearch_aws_secret_access_key',
elasticsearch_aws_region: 'elasticsearch_aws_region',
elasticsearch_search: true,
repository_size_limit: 1024,
shared_runners_minutes: 60,
geo_status_timeout: 30,
......@@ -62,25 +36,10 @@ RSpec.describe Admin::ApplicationSettingsController do
put :update, params: { application_setting: settings }
expect(response).to redirect_to(general_admin_application_settings_path)
settings.except(:elasticsearch_url, :repository_size_limit).each do |setting, value|
settings.except(:repository_size_limit).each do |setting, value|
expect(ApplicationSetting.current.public_send(setting)).to eq(value)
end
expect(ApplicationSetting.current.repository_size_limit).to eq(settings[:repository_size_limit].megabytes)
expect(ApplicationSetting.current.elasticsearch_url).to contain_exactly(settings[:elasticsearch_url])
end
context 'elasticsearch_aws_secret_access_key setting is blank' do
let(:settings) do
{
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: ''
}
end
it 'does not update the elasticsearch_aws_secret_access_key setting' do
expect { put :update, params: { application_setting: settings } }
.not_to change { ApplicationSetting.current.reload.elasticsearch_aws_secret_access_key }
end
end
shared_examples 'settings for licensed features' do
......@@ -323,6 +282,62 @@ RSpec.describe Admin::ApplicationSettingsController do
end
end
describe '#advanced_search' do
before do
sign_in(admin)
@request.env['HTTP_REFERER'] = advanced_search_admin_application_settings_path
end
context 'advanced search settings' do
it 'updates the advanced search settings' do
settings = {
elasticsearch_url: 'http://my-elastic.search:9200',
elasticsearch_indexing: false,
elasticsearch_aws: true,
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: 'elasticsearch_aws_secret_access_key',
elasticsearch_aws_region: 'elasticsearch_aws_region',
elasticsearch_search: true
}
patch :advanced_search, params: { application_setting: settings }
expect(response).to redirect_to(advanced_search_admin_application_settings_path)
settings.except(:elasticsearch_url).each do |setting, value|
expect(ApplicationSetting.current.public_send(setting)).to eq(value)
end
expect(ApplicationSetting.current.elasticsearch_url).to contain_exactly(settings[:elasticsearch_url])
end
end
context 'zero-downtime elasticsearch reindexing' do
render_views
let!(:task) { create(:elastic_reindexing_task) }
it 'assigns elasticsearch reindexing task' do
get :advanced_search
expect(assigns(:elasticsearch_reindexing_task)).to eq(task)
expect(response.body).to include("Reindexing Status: #{task.state}")
end
end
context 'elasticsearch_aws_secret_access_key setting is blank' do
let(:settings) do
{
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: ''
}
end
it 'does not update the elasticsearch_aws_secret_access_key setting' do
expect { patch :advanced_search, params: { application_setting: settings } }
.not_to change { ApplicationSetting.current.reload.elasticsearch_aws_secret_access_key }
end
end
end
describe 'GET #seat_link_payload' do
context 'when a non-admin user attempts a request' do
before do
......
......@@ -21,7 +21,7 @@ RSpec.describe Admin::ElasticsearchController do
post :enqueue_index
expect(controller).to set_flash[:notice].to include('/admin/sidekiq/queues/elastic_commit_indexer')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
context 'without an index' do
......@@ -35,7 +35,7 @@ RSpec.describe Admin::ElasticsearchController do
post :enqueue_index
expect(controller).to set_flash[:warning].to include('create an index before enabling indexing')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
end
end
......@@ -51,7 +51,7 @@ RSpec.describe Admin::ElasticsearchController do
post :trigger_reindexing
expect(controller).to set_flash[:notice].to include('reindexing triggered')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
it 'does not create a reindexing task if there is another one' do
......@@ -61,7 +61,7 @@ RSpec.describe Admin::ElasticsearchController do
post :trigger_reindexing
expect(controller).to set_flash[:warning].to include('already in progress')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
end
......@@ -77,7 +77,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(task.reload.delete_original_index_at).to be_nil
expect(controller).to set_flash[:notice].to include('deletion is canceled')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
end
......@@ -100,7 +100,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(Elastic::DataMigrationService.halted_migrations?).to be_falsey
expect(controller).to set_flash[:notice].to include('Migration has been scheduled to be retried')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end
end
end
......@@ -53,11 +53,11 @@ RSpec.describe 'Admin updates EE-only settings' do
end
context 'Elasticsearch settings' do
let(:elastic_search_license) { true }
before do
visit general_admin_application_settings_path
page.within('.as-elasticsearch') do
click_button 'Expand'
end
stub_licensed_features(elastic_search: elastic_search_license)
visit advanced_search_admin_application_settings_path
end
it 'changes elasticsearch settings' do
......@@ -138,14 +138,12 @@ RSpec.describe 'Admin updates EE-only settings' do
namespace = create(:elasticsearch_indexed_namespace).namespace
project = create(:elasticsearch_indexed_project).project
visit general_admin_application_settings_path
visit advanced_search_admin_application_settings_path
expect(ElasticsearchIndexedNamespace.count).to be > 0
expect(ElasticsearchIndexedProject.count).to be > 0
page.within('.as-elasticsearch') do
click_button 'Expand'
expect(page).to have_content('Namespaces to index')
expect(page).to have_content('Projects to index')
expect(page).to have_content(namespace.full_path)
......@@ -175,6 +173,14 @@ RSpec.describe 'Admin updates EE-only settings' do
expect(text).to eq 'Are you sure you want to reindex?'
page.driver.browser.switch_to.alert.accept
end
context 'when not licensed' do
let(:elastic_search_license) { false }
it 'cannot access the page' do
expect(page).not_to have_content("Advanced Search with Elasticsearch")
end
end
end
it 'enable Slack application' do
......
......@@ -105,5 +105,10 @@ RSpec.describe 'EE-specific admin routing' do
expect(get('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
expect(patch('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
end
it 'redirects /advanced_search to to #advanced_search' do
expect(get('/admin/application_settings/advanced_search')).to route_to('admin/application_settings#advanced_search')
expect(patch('/admin/application_settings/advanced_search')).to route_to('admin/application_settings#advanced_search')
end
end
end
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_admin' do
context 'on settings' do
context 'on templates settings' do
before do
stub_licensed_features(custom_file_templates: custom_file_templates)
......@@ -26,4 +26,28 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
end
end
end
context 'on advanced search settings' do
before do
stub_licensed_features(elastic_search: elastic_search_license)
render
end
context 'license with elastic_search feature' do
let(:elastic_search_license) { true }
it 'includes Advanced Search link' do
expect(rendered).to have_link('Advanced Search', href: '/admin/application_settings/advanced_search')
end
end
context 'license without elastic_search feature' do
let(:elastic_search_license) { false }
it 'includes Advanced Search link' do
expect(rendered).not_to have_link('Advanced Search', href: '/admin/application_settings/advanced_search')
end
end
end
end
......@@ -2023,9 +2023,6 @@ msgstr ""
msgid "AdminSettings|Disable feed token"
msgstr ""
msgid "AdminSettings|Elasticsearch, PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings &gt; General."
msgstr ""
msgid "AdminSettings|Enable shared runners for new projects"
msgstr ""
......@@ -2047,6 +2044,9 @@ msgstr ""
msgid "AdminSettings|No required pipeline"
msgstr ""
msgid "AdminSettings|PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings &gt; General."
msgstr ""
msgid "AdminSettings|Required pipeline configuration"
msgstr ""
......
......@@ -81,7 +81,6 @@ module QA
module Settings
autoload :Templates, 'qa/ee/page/admin/settings/templates'
autoload :Elasticsearch, 'qa/ee/page/admin/settings/elasticsearch'
autoload :Preferences, 'qa/ee/page/admin/settings/preferences'
module Component
......
......@@ -13,6 +13,7 @@ module QA
base.class_eval do
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
element :admin_settings_template_item
element :admin_settings_advanced_search
end
view 'ee/app/views/layouts/nav/ee/admin/_geo_sidebar.html.haml' do
......@@ -52,6 +53,14 @@ module QA
end
end
end
def go_to_advanced_search
hover_element(:admin_settings_item) do
within_submenu(:admin_sidebar_settings_submenu_content) do
click_element :admin_settings_advanced_search
end
end
end
end
end
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
class Elasticsearch < QA::Page::Base
include QA::Page::Settings::Common
view 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml' do
element :elasticsearch_tab
end
def expand_elasticsearch(&block)
expand_content(:elasticsearch_tab) do
Component::Elasticsearch.perform(&block)
end
end
end
end
end
end
end
end
......@@ -17,15 +17,14 @@ module QA
def fabricate!
QA::Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_general_settings)
QA::EE::Page::Admin::Settings::Elasticsearch.perform do |settings|
settings.expand_elasticsearch do |es|
QA::Page::Admin::Menu.perform(&:go_to_advanced_search)
QA::EE::Page::Admin::Settings::Component::Elasticsearch.perform do |es|
es.check_indexing if @es_indexing
es.check_search if @es_enabled
es.enter_link(@es_url)
es.click_submit
end
end
sleep(90)
# wait for the change to propagate before inserting records or else
# Gitlab::CurrentSettings.elasticsearch_indexing and
......
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