Commit c6e8bde2 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '218252-add-feature-flag-and-basic-frontend' into 'master'

Add feature flag and basic frontend sctructure for instance-level integration overrides

See merge request gitlab-org/gitlab!66723
parents 5894ca6c c1d3ce94
<script>
export default {
name: 'IntegrationOverrides',
props: {
overridesPath: {
type: String,
required: true,
},
},
};
</script>
<template>
<div></div>
</template>
import Vue from 'vue';
import IntegrationOverrides from './components/integration_overrides.vue';
export default () => {
const el = document.querySelector('.js-vue-integration-overrides');
if (!el) {
return null;
}
const { overridesPath } = el.dataset;
return new Vue({
el,
render(createElement) {
return createElement(IntegrationOverrides, {
props: {
overridesPath,
},
});
},
});
};
import initIntegrationOverrides from '~/integrations/overrides';
initIntegrationOverrides();
......@@ -2,13 +2,14 @@
class Admin::IntegrationsController < Admin::ApplicationController
include IntegrationsActions
include IntegrationsHelper
before_action :not_found, unless: -> { instance_level_integrations? }
feature_category :integrations
def overrides
return render_404 unless instance_level_integration_overrides?
respond_to do |format|
format.json do
projects = Project.with_active_integration(integration.class).merge(::Integration.not_inherited)
......@@ -16,7 +17,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
render json: serializer.represent(projects)
end
# TODO frontend will add format.html
format.html { render 'shared/integrations/overrides' }
end
end
......@@ -26,7 +27,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
Integration.find_or_initialize_non_project_specific_integration(name, instance: true)
end
def scoped_edit_integration_path(integration)
edit_admin_application_settings_integration_path(integration)
def instance_level_integration_overrides?
Feature.enabled?(:instance_level_integration_overrides, default_enabled: :yaml)
end
end
......@@ -5,8 +5,9 @@ module IntegrationsActions
included do
include Integrations::Params
include IntegrationsHelper
before_action :integration, only: [:edit, :update, :test]
before_action :integration, only: [:edit, :update, :overrides, :test]
end
def edit
......
......@@ -26,10 +26,6 @@ module Groups
def find_or_initialize_non_project_specific_integration(name)
Integration.find_or_initialize_non_project_specific_integration(name, group_id: group.id)
end
def scoped_edit_integration_path(integration)
edit_group_settings_integration_path(group, integration)
end
end
end
end
......@@ -47,6 +47,10 @@ module IntegrationsHelper
end
end
def scoped_overrides_integration_path(integration, options = {})
overrides_admin_application_settings_integration_path(integration, options)
end
def scoped_test_integration_path(integration)
if @project.present?
test_project_service_path(@project, integration)
......@@ -97,6 +101,12 @@ module IntegrationsHelper
form_data
end
def integration_overrides_data(integration)
{
overrides_path: scoped_overrides_integration_path(integration, format: :json)
}
end
def integration_list_data(integrations)
{
integrations: integrations.map { |i| serialize_integration(i) }.to_json
......
.tabs.gl-tabs
%div
%ul.nav.gl-tabs-nav{ role: 'tablist' }
%li.nav-item{ role: 'presentation' }
%a.nav-link.gl-tab-nav-item{ role: 'tab', href: scoped_edit_integration_path(integration) }
= _('Settings')
%li.nav-item{ role: 'presentation' }
%a.nav-link.gl-tab-nav-item.gl-tab-nav-item-active.gl-tab-nav-item-active-indigo.active{ role: 'tab', href: scoped_overrides_integration_path(integration) }
= s_('Integrations|Projects using custom settings')
.tab-content.gl-tab-content
.tab-pane.active{ role: 'tabpanel' }
= yield
- add_to_breadcrumbs _('Integrations'), scoped_integrations_path
- breadcrumb_title @integration.title
- page_title @integration.title, _('Integrations')
- @content_class = 'limit-container-width' unless fluid_layout
%h3.page-title
= @integration.title
= render 'shared/integrations/tabs', integration: @integration do
.js-vue-integration-overrides{ data: integration_overrides_data(@integration) }
---
name: instance_level_integration_overrides
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66723
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/336750
milestone: '14.2'
type: development
group: group::ecosystem
default_enabled: false
......@@ -17711,6 +17711,9 @@ msgstr ""
msgid "Integrations|Note: this integration only works with accounts on GitLab.com (SaaS)."
msgstr ""
msgid "Integrations|Projects using custom settings"
msgstr ""
msgid "Integrations|Projects using custom settings will not be affected."
msgstr ""
......
......@@ -105,17 +105,44 @@ RSpec.describe Admin::IntegrationsController do
let_it_be(:overridden_other_integration) { create(:confluence_integration) }
subject do
get :overrides, params: { id: instance_integration.class.to_param }, format: :json
get :overrides, params: { id: instance_integration.class.to_param }, format: format
end
include_context 'JSON response'
context 'when format is JSON' do
let(:format) { :json }
it 'returns projects with overrides', :aggregate_failures do
subject
include_context 'JSON response'
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to contain_exactly(a_hash_including('full_name' => overridden_integration.project.full_name))
it 'returns projects with overrides', :aggregate_failures do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to contain_exactly(a_hash_including('full_name' => overridden_integration.project.full_name))
end
end
context 'when format is HTML' do
let(:format) { :html }
it 'renders template' do
subject
expect(response).to render_template 'shared/integrations/overrides'
expect(assigns(:integration)).to eq(instance_integration)
end
context 'when `instance_level_integration_overrides` is not enabled' do
before do
stub_feature_flags(instance_level_integration_overrides: false)
end
it 'renders a 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
end
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