Commit b2658e86 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '9486-insights-config-file' into 'master'

Resolve "Insights config file"

Closes #9486

See merge request gitlab-org/gitlab-ee!9665
parents b262ee9c f19cc58e
......@@ -25,6 +25,8 @@
.settings-content
= render 'groups/settings/permissions'
= render_if_exists 'groups/insights', expanded: expanded
%section.settings.no-animate#js-badge-settings{ class: ('expanded' if expanded) }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only{ role: 'button' }
......
......@@ -1490,6 +1490,13 @@ ActiveRecord::Schema.define(version: 20190301182031) do
t.index ["project_id"], name: "index_index_statuses_on_project_id", unique: true, using: :btree
end
create_table "insights", force: :cascade do |t|
t.integer "namespace_id", null: false
t.integer "project_id", null: false
t.index ["namespace_id"], name: "index_insights_on_namespace_id", using: :btree
t.index ["project_id"], name: "index_insights_on_project_id", using: :btree
end
create_table "internal_ids", id: :bigserial, force: :cascade do |t|
t.integer "project_id"
t.integer "usage", null: false
......@@ -3444,6 +3451,8 @@ ActiveRecord::Schema.define(version: 20190301182031) do
add_foreign_key "identities", "saml_providers", name: "fk_aade90f0fc", on_delete: :cascade
add_foreign_key "import_export_uploads", "projects", on_delete: :cascade
add_foreign_key "index_statuses", "projects", name: "fk_74b2492545", on_delete: :cascade
add_foreign_key "insights", "namespaces"
add_foreign_key "insights", "projects"
add_foreign_key "internal_ids", "namespaces", name: "fk_162941d509", on_delete: :cascade
add_foreign_key "internal_ids", "projects", on_delete: :cascade
add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade
......
......@@ -201,6 +201,10 @@ Get an overview of the vulnerabilities of all the projects in a group and its su
[Learn more about the Group Security Dashboard.](security_dashboard/index.md)
## Insights **[ULTIMATE]**
Placeholder.
## Transfer groups to another group
From 10.5 there are two different ways to transfer a group:
......
......@@ -15,6 +15,7 @@ module EE
:membership_lock,
:repository_size_limit
].tap do |params_ee|
params_ee << { insight_attributes: :project_id } if ::Feature.enabled?(:group_insights) && current_group&.feature_available?(:insights)
params_ee << :project_creation_level if current_group&.feature_available?(:project_creation_level)
params_ee << :file_template_project_id if current_group&.feature_available?(:custom_file_templates_for_namespace)
params_ee << :custom_project_templates_group_id if License.feature_available?(:custom_project_templates)
......
......@@ -17,6 +17,8 @@ module EE
has_many :epics
has_one :saml_provider
has_one :insight, foreign_key: :namespace_id
accepts_nested_attributes_for :insight
has_many :ldap_group_links, foreign_key: 'group_id', dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :hooks, dependent: :destroy, class_name: 'GroupHook' # rubocop:disable Cop/ActiveRecordDependent
......
# frozen_string_literal: true
class Insight < ActiveRecord::Base
belongs_to :group, foreign_key: :namespace_id
belongs_to :project
end
......@@ -75,7 +75,8 @@ class License < ActiveRecord::Base
batch_comments
issues_analytics
merge_pipelines
].freeze
]
EEP_FEATURES.freeze
EEU_FEATURES = EEP_FEATURES + %i[
security_dashboard
......@@ -92,8 +93,10 @@ class License < ActiveRecord::Base
prometheus_alerts
operations_dashboard
tracing
insights
web_ide_terminal
].freeze
]
EEU_FEATURES.freeze
# List all features available for early adopters,
# i.e. users that started using GitLab.com before
......
......@@ -18,5 +18,5 @@
Select a
= link_to 'template repository', help_page_path("user/admin_area/settings/instance_template_repository")
= project_select_tag('application_setting[file_template_project_id]', class: 'project-item-select hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: admin_project_dropdown_label('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_projects: 'true', simple_filter: true, allow_clear: true}, value: @application_setting.file_template_project_id)
placeholder: admin_project_dropdown_label('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_projects: 'true', simple_filter: true, allow_clear: true }, value: @application_setting.file_template_project_id)
= f.submit 'Save changes', class: "btn btn-success"
......@@ -20,11 +20,11 @@
- elsif params[:event_type] == 'Project'
.filter-item.inline
= project_select_tag(:project_id, { class: 'project-item-select hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: admin_project_dropdown_label('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_projects: 'true', simple_filter: true} })
placeholder: admin_project_dropdown_label('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_projects: 'true', simple_filter: true } })
- elsif params[:event_type] == 'Group'
.filter-item.inline
= groups_select_tag(:group_id, { required: true, class: 'group-item-select project-item-select hidden-filter-value', toggle_class: 'js-group-search js-group-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-group js-filter-submit',
placeholder: admin_namespace_dropdown_label('Search groups'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_available: true} })
placeholder: admin_namespace_dropdown_label('Search groups'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', all_available: true } })
- if @events.present?
%table#events-table.table
......
- return unless Feature.enabled?(:group_insights) && @group.feature_available?(:insights)
%section.settings.gs-advanced.no-animate#js-templates{ class: ('expanded' if expanded) }
.settings-header
%h4
= _('Insights')
%button.btn.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _('Select a project to read Insights configuration file')
.settings-content
= form_for @group, url: group_path, html: { class: 'fieldset-form' } do |form|
= form_errors(@group)
%fieldset
.form-group
- insight = @group.insight || @group.build_insight
= form.fields_for :insight_attributes, insight do |insight_form|
= insight_form.label :project_id, class: 'label-light' do
.form-text.text-muted
= _('Select a repository')
= link_to icon('question-circle'), help_page_path('user/group/index.md', anchor: 'insights-ultimate'), target: '_blank'
= project_select_tag('group[insight_attributes][project_id]', class: 'project-item-select hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: _('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true }, value: insight.project_id)
= form.submit _('Save changes'), class: "btn btn-success"
......@@ -19,5 +19,5 @@
= _('Select a template repository')
= link_to icon('question-circle'), help_page_path('user/group/index.md', anchor: 'group-level-file-templates-premium'), target: '_blank'
= project_select_tag('group[file_template_project_id]', class: 'project-item-select hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: _('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true}, value: @group.checked_file_template_project_id)
placeholder: _('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true }, value: @group.checked_file_template_project_id)
= f.submit _('Save changes'), class: "btn btn-success"
---
title: Add Insights config behind the "group_insights" feature flag
merge_request: 9665
author:
type: added
# frozen_string_literal: true
class CreateInsights < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :insights do |t|
t.references :namespace, index: true, foreign_key: true, null: false
t.references :project, index: true, foreign_key: true, null: false
end
end
end
......@@ -80,6 +80,16 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { file_template_project_id: project.id } }
end.not_to change { group.reload.file_template_project_id }
end
it 'does not update insight project_id successfully' do
project = create(:project, group: group)
stub_licensed_features(insights: false)
post :update, params: { id: group.to_param, group: { insight_attributes: { project_id: project.id } } }
expect(group.reload.insight).to be_nil
end
end
context 'with license' do
......@@ -92,6 +102,16 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { file_template_project_id: project.id } }
end.to change { group.reload.file_template_project_id }.to(project.id)
end
it 'updates insight project_id successfully' do
project = create(:project, group: group)
stub_licensed_features(insights: true)
post :update, params: { id: group.to_param, group: { insight_attributes: { project_id: project.id } } }
expect(group.reload.insight.project).to eq(project)
end
end
end
......
......@@ -5474,6 +5474,9 @@ msgstr ""
msgid "Insert suggestion"
msgstr ""
msgid "Insights"
msgstr ""
msgid "Install GitLab Runner"
msgstr ""
......@@ -8771,6 +8774,12 @@ msgstr ""
msgid "Select a namespace to fork the project"
msgstr ""
msgid "Select a project to read Insights configuration file"
msgstr ""
msgid "Select a repository"
msgstr ""
msgid "Select a template repository"
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