Commit 75d6c1d6 authored by Himanshu Kapoor's avatar Himanshu Kapoor Committed by Denys Mishunov

Use a common layout for settings controllers

Make sure all the settings controllers use the `project_settings` layout
parent 6ce88e04
import initSearchSettings from '~/search_settings';
initSearchSettings();
import initSearchSettings from '~/search_settings';
initSearchSettings();
...@@ -6,7 +6,6 @@ import initDeployFreeze from '~/deploy_freeze'; ...@@ -6,7 +6,6 @@ import initDeployFreeze from '~/deploy_freeze';
import { initInstallRunner } from '~/pages/shared/mount_runner_instructions'; import { initInstallRunner } from '~/pages/shared/mount_runner_instructions';
import initSharedRunnersToggle from '~/projects/settings/mount_shared_runners_toggle'; import initSharedRunnersToggle from '~/projects/settings/mount_shared_runners_toggle';
import registrySettingsApp from '~/registry/settings/registry_settings_bundle'; import registrySettingsApp from '~/registry/settings/registry_settings_bundle';
import initSearchSettings from '~/search_settings';
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
...@@ -43,6 +42,4 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -43,6 +42,4 @@ document.addEventListener('DOMContentLoaded', () => {
} }
initInstallRunner(); initInstallRunner();
initSearchSettings();
}); });
import initSearchSettings from '~/search_settings';
initSearchSettings();
...@@ -3,7 +3,6 @@ import mountErrorTrackingForm from '~/error_tracking_settings'; ...@@ -3,7 +3,6 @@ import mountErrorTrackingForm from '~/error_tracking_settings';
import mountGrafanaIntegration from '~/grafana_integration'; import mountGrafanaIntegration from '~/grafana_integration';
import initIncidentsSettings from '~/incidents_settings'; import initIncidentsSettings from '~/incidents_settings';
import mountOperationSettings from '~/operation_settings'; import mountOperationSettings from '~/operation_settings';
import initSearchSettings from '~/search_settings';
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
initIncidentsSettings(); initIncidentsSettings();
...@@ -14,7 +13,3 @@ if (!IS_EE) { ...@@ -14,7 +13,3 @@ if (!IS_EE) {
initSettingsPanels(); initSettingsPanels();
} }
mountAlertsSettings(document.querySelector('.js-alerts-settings')); mountAlertsSettings(document.querySelector('.js-alerts-settings'));
document.addEventListener('DOMContentLoaded', () => {
initSearchSettings();
});
import MirrorRepos from '~/mirrors/mirror_repos'; import MirrorRepos from '~/mirrors/mirror_repos';
import initSearchSettings from '~/search_settings';
import initForm from '../form'; import initForm from '../form';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
...@@ -7,6 +6,4 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -7,6 +6,4 @@ document.addEventListener('DOMContentLoaded', () => {
const mirrorReposContainer = document.querySelector('.js-mirror-settings'); const mirrorReposContainer = document.querySelector('.js-mirror-settings');
if (mirrorReposContainer) new MirrorRepos(mirrorReposContainer).init(); if (mirrorReposContainer) new MirrorRepos(mirrorReposContainer).init();
initSearchSettings();
}); });
...@@ -5,6 +5,7 @@ module Projects ...@@ -5,6 +5,7 @@ module Projects
class AccessTokensController < Projects::ApplicationController class AccessTokensController < Projects::ApplicationController
include ProjectsHelper include ProjectsHelper
layout 'project_settings'
before_action :check_feature_availability before_action :check_feature_availability
feature_category :authentication_and_authorization feature_category :authentication_and_authorization
......
...@@ -7,6 +7,7 @@ module Projects ...@@ -7,6 +7,7 @@ module Projects
NUMBER_OF_RUNNERS_PER_PAGE = 20 NUMBER_OF_RUNNERS_PER_PAGE = 20
layout 'project_settings'
before_action :authorize_admin_pipeline! before_action :authorize_admin_pipeline!
before_action :define_variables before_action :define_variables
before_action do before_action do
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Projects module Projects
module Settings module Settings
class OperationsController < Projects::ApplicationController class OperationsController < Projects::ApplicationController
layout 'project_settings'
before_action :authorize_admin_operations! before_action :authorize_admin_operations!
before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token] before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token]
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Projects module Projects
module Settings module Settings
class RepositoryController < Projects::ApplicationController class RepositoryController < Projects::ApplicationController
layout 'project_settings'
before_action :authorize_admin_project! before_action :authorize_admin_project!
before_action :define_variables, only: [:create_deploy_token] before_action :define_variables, only: [:create_deploy_token]
before_action do before_action do
......
- page_title _("Settings") - page_title _("Settings")
- nav "project" - nav "project"
- enable_search_settings locals: { container_class: 'gl-my-5' }
= render template: "layouts/project" = render template: "layouts/project"
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- expanded = expanded_by_default? - expanded = expanded_by_default?
- enable_search_settings
%section.settings.general-settings.no-animate.expanded#js-general-settings %section.settings.general-settings.no-animate.expanded#js-general-settings
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Naming, topics, avatar') %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Naming, topics, avatar')
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
- expanded = expanded_by_default? - expanded = expanded_by_default?
- general_expanded = @project.errors.empty? ? expanded : true - general_expanded = @project.errors.empty? ? expanded : true
- enable_search_settings locals: { container_class: 'gl-my-5' }
%section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded), data: { qa_selector: 'general_pipelines_settings_content' } } %section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded), data: { qa_selector: 'general_pipelines_settings_content' } }
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
- page_title _('Operations Settings') - page_title _('Operations Settings')
- breadcrumb_title _('Operations Settings') - breadcrumb_title _('Operations Settings')
- enable_search_settings locals: { container_class: 'gl-my-5' }
= render 'projects/settings/operations/alert_management' = render 'projects/settings/operations/alert_management'
= render 'projects/settings/operations/incidents' = render 'projects/settings/operations/incidents'
= render 'projects/settings/operations/error_tracking' = render 'projects/settings/operations/error_tracking'
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- deploy_token_description = s_('DeployTokens|Deploy tokens allow access to packages, your repository, and registry images.') - deploy_token_description = s_('DeployTokens|Deploy tokens allow access to packages, your repository, and registry images.')
- enable_search_settings locals: { container_class: 'gl-my-5' }
= render "projects/default_branch/show" = render "projects/default_branch/show"
= render_if_exists "projects/push_rules/index" = render_if_exists "projects/push_rules/index"
= render "projects/mirrors/mirror_repos" = render "projects/mirrors/mirror_repos"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
- add_page_specific_style 'page_bundles/wiki' - add_page_specific_style 'page_bundles/wiki'
.wiki-page-header.top-area.flex-column.flex-lg-row .wiki-page-header.top-area.flex-column.flex-lg-row
%h3.page-title.gl-flex-fill-1 %h3.page-title.gl-flex-fill-1
= s_("Wiki|Wiki Pages") = s_("Wiki|Wiki Pages")
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'User searches project settings', :js do RSpec.describe 'User searches project settings', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace, pages_https_only: false) }
before do before do
sign_in(user) sign_in(user)
...@@ -16,6 +16,30 @@ RSpec.describe 'User searches project settings', :js do ...@@ -16,6 +16,30 @@ RSpec.describe 'User searches project settings', :js do
it_behaves_like 'can search settings with feature flag check', 'Naming', 'Visibility' it_behaves_like 'can search settings with feature flag check', 'Naming', 'Visibility'
end end
context 'in Integrations page' do
before do
visit project_settings_integrations_path(project)
end
it_behaves_like 'can highlight results', 'third-party applications'
end
context 'in Webhooks page' do
before do
visit project_hooks_path(project)
end
it_behaves_like 'can highlight results', 'Secret token'
end
context 'in Access Tokens page' do
before do
visit project_settings_access_tokens_path(project)
end
it_behaves_like 'can highlight results', 'Expires at'
end
context 'in Repository page' do context 'in Repository page' do
before do before do
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
...@@ -39,4 +63,14 @@ RSpec.describe 'User searches project settings', :js do ...@@ -39,4 +63,14 @@ RSpec.describe 'User searches project settings', :js do
it_behaves_like 'can search settings', 'Alerts', 'Error tracking' it_behaves_like 'can search settings', 'Alerts', 'Error tracking'
end end
context 'in Pages page' do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
visit project_pages_path(project)
end
it_behaves_like 'can highlight results', 'static websites'
end
end end
...@@ -7,9 +7,7 @@ RSpec.shared_examples 'cannot search settings' do ...@@ -7,9 +7,7 @@ RSpec.shared_examples 'cannot search settings' do
end end
RSpec.shared_examples 'can search settings' do |search_term, non_match_section| RSpec.shared_examples 'can search settings' do |search_term, non_match_section|
it 'has search settings field' do it_behaves_like 'can highlight results', search_term
expect(page).to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
end
it 'hides unmatching sections on search' do it 'hides unmatching sections on search' do
expect(page).to have_content(non_match_section) expect(page).to have_content(non_match_section)
...@@ -21,6 +19,23 @@ RSpec.shared_examples 'can search settings' do |search_term, non_match_section| ...@@ -21,6 +19,23 @@ RSpec.shared_examples 'can search settings' do |search_term, non_match_section|
end end
end end
RSpec.shared_examples 'can highlight results' do |search_term|
it 'has search settings field' do
expect(page).to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
end
it 'highlights the search terms' do
selector = '.gl-bg-orange-50'
fill_in SearchHelpers::INPUT_PLACEHOLDER, with: search_term
expect(page).to have_css(selector)
page.find_all(selector) do |element|
expect(element).to have_content(search_term)
end
end
end
RSpec.shared_examples 'can search settings with feature flag check' do |search_term, non_match_section| RSpec.shared_examples 'can search settings with feature flag check' do |search_term, non_match_section|
let(:flag) { true } let(:flag) { true }
......
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