Commit ae484e90 authored by Arturo Herrero's avatar Arturo Herrero

Fix visibily of project services

This refactor improves the exclusion of disabled project services
removing the service exceptions parameter.

We were not listing the disabled project services but we were able to
edit the individual service if we know the valid URL. This commit fixes
that discrepancy between index and show.
parent 3f7e979a
......@@ -7,17 +7,8 @@ module Projects
layout "project_settings"
def show
@services = @project.find_or_initialize_services(exceptions: service_exceptions)
end
private
# Returns a list of services that should be hidden from the list
def service_exceptions
@project.disabled_services.dup
@services = @project.find_or_initialize_services
end
end
end
end
Projects::Settings::IntegrationsController.prepend_if_ee('EE::Projects::Settings::IntegrationsController')
......@@ -1238,14 +1238,12 @@ class Project < ApplicationRecord
update_column(:has_external_wiki, services.external_wikis.any?) if Gitlab::Database.read_write?
end
def find_or_initialize_services(exceptions: [])
available_services_names = Service.available_services_names - exceptions
def find_or_initialize_services
available_services_names = Service.available_services_names - disabled_services
available_services = available_services_names.map do |service_name|
available_services_names.map do |service_name|
find_or_initialize_service(service_name)
end
available_services.compact
end
def disabled_services
......
# frozen_string_literal: true
module EE
module Projects
module Settings
module IntegrationsController
extend ::Gitlab::Utils::Override
private
override :service_exceptions
def service_exceptions
super << slack_service
end
def slack_service
if ::Gitlab::CurrentSettings.slack_app_enabled
'slack_slash_commands'
else
'gitlab_slack_application'
end
end
end
end
end
end
......@@ -545,6 +545,7 @@ module EE
[].tap do |services|
services.push('jenkins', 'jenkins_deprecated') unless feature_available?(:jenkins_integration)
services.push('github') unless feature_available?(:github_project_service_integration)
::Gitlab::CurrentSettings.slack_app_enabled ? services.push('slack_slash_commands') : services.push('gitlab_slack_application')
end
end
end
......
......@@ -16,6 +16,7 @@ describe 'Slack application' do
create(:slack_integration, service: service)
allow(Gitlab).to receive(:com?).and_return(true)
allow(Gitlab::CurrentSettings).to receive(:slack_app_enabled).and_return(true)
end
it 'I can edit slack integration' do
......
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