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

Merge branch '119429-decouple-webhooks-from-integrations-within-project-settings' into 'master'

Decouple Webhooks from Integrations within Project > Settings

See merge request gitlab-org/gitlab!23136
parents a96760d0 45f6f105
import PersistentUserCallout from '~/persistent_user_callout';
document.addEventListener('DOMContentLoaded', () => {
const callout = document.querySelector('.js-webhooks-moved-alert');
PersistentUserCallout.factory(callout);
});
......@@ -12,7 +12,8 @@ class Projects::HooksController < Projects::ApplicationController
layout "project_settings"
def index
redirect_to project_settings_integrations_path(@project)
@hooks = @project.hooks
@hook = ProjectHook.new
end
def create
......@@ -24,7 +25,7 @@ class Projects::HooksController < Projects::ApplicationController
flash[:alert] = @hook.errors.full_messages.join.html_safe
end
redirect_to project_settings_integrations_path(@project)
redirect_to action: :index
end
def edit
......@@ -33,7 +34,7 @@ class Projects::HooksController < Projects::ApplicationController
def update
if hook.update(hook_params)
flash[:notice] = _('Hook was successfully updated.')
redirect_to project_settings_integrations_path(@project)
redirect_to action: :index
else
render 'edit'
end
......@@ -44,13 +45,13 @@ class Projects::HooksController < Projects::ApplicationController
set_hook_execution_notice(result)
redirect_back_or_default(default: { action: 'index' })
redirect_back_or_default(default: { action: :index })
end
def destroy
hook.destroy
redirect_to project_settings_integrations_path(@project), status: :found
redirect_to action: :index, status: :found
end
private
......
......@@ -9,10 +9,6 @@ module Projects
layout "project_settings"
def show
@hooks = @project.hooks
@hook = ProjectHook.new
# Services
@services = @project.find_or_initialize_services(exceptions: service_exceptions)
end
......
......@@ -669,6 +669,9 @@ module ProjectsHelper
project_members#index
integrations#show
services#edit
hooks#index
hooks#edit
hook_logs#show
repository#show
ci_cd#show
operations#show
......
......@@ -5,6 +5,7 @@ module UserCalloutsHelper
GCP_SIGNUP_OFFER = 'gcp_signup_offer'
SUGGEST_POPOVER_DISMISSED = 'suggest_popover_dismissed'
TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight'
WEBHOOKS_MOVED = 'webhooks_moved'
def show_gke_cluster_integration_callout?(project)
can?(current_user, :create_cluster, project) &&
......@@ -33,6 +34,10 @@ module UserCalloutsHelper
current_user && !user_dismissed?(TABS_POSITION_HIGHLIGHT) && !Rails.env.test?
end
def show_webhooks_moved_alert?
!user_dismissed?(WEBHOOKS_MOVED)
end
private
def user_dismissed?(feature_name, ignore_dismissal_earlier_than = nil)
......
......@@ -21,7 +21,7 @@ class ProjectHook < WebHook
validates :project, presence: true
def pluralized_name
_('Project Hooks')
_('Webhooks')
end
end
......
......@@ -15,7 +15,8 @@ module UserCalloutEnums
gcp_signup_offer: 2,
cluster_security_warning: 3,
suggest_popover_dismissed: 9,
tabs_position_highlight: 10
tabs_position_highlight: 10,
webhooks_moved: 13
}
end
end
......
......@@ -366,10 +366,14 @@
%span
= _('Members')
- if can_edit
= nav_link(controller: [:integrations, :services, :hooks, :hook_logs]) do
= nav_link(controller: [:integrations, :services]) do
= link_to project_settings_integrations_path(@project), title: _('Integrations'), data: { qa_selector: 'integrations_settings_link' } do
%span
= _('Integrations')
= nav_link(controller: [:hooks, :hook_logs]) do
= link_to project_hooks_path(@project), title: _('Webhooks'), data: { qa_selector: 'webhooks_settings_link' } do
%span
= _('Webhooks')
= nav_link(controller: :repository) do
= link_to project_settings_repository_path(@project), title: _('Repository') do
%span
......
- @content_class = 'limit-container-width' unless fluid_layout
- add_to_breadcrumbs _('Webhook Settings'), namespace_project_hooks_path
- page_title _('Webhook Logs')
.row.prepend-top-default.append-bottom-default
.col-lg-3
%h4.prepend-top-0
......
- add_to_breadcrumbs _('ProjectService|Integrations'), namespace_project_settings_integrations_path
- page_title _('Edit Project Hook')
- @content_class = 'limit-container-width' unless fluid_layout
- add_to_breadcrumbs _('Webhook Settings'), namespace_project_hooks_path
- page_title _('Webhook')
.row.prepend-top-default
.col-lg-3
......
- @content_class = 'limit-container-width' unless fluid_layout
- breadcrumb_title _('Webhook Settings')
- page_title _('Webhooks')
.row.prepend-top-default
.col-lg-4
= render 'shared/web_hooks/title_and_docs', hook: @hook
......
.row.prepend-top-default.append-bottom-default
.row.prepend-top-default
.col-lg-4
%h4.prepend-top-0
= s_("ProjectService|Project services")
%p= s_("ProjectService|Project services allow you to integrate GitLab with other applications")
= _('Integrations')
%p= _('Integrations allow you to integrate GitLab with other applications')
.col-lg-8
%table.table
%colgroup
......
- breadcrumb_title @service.title
- add_to_breadcrumbs _('Integration Settings'), project_settings_integrations_path(@project)
- page_title @service.title, s_("ProjectService|Services")
- add_to_breadcrumbs(s_("ProjectService|Settings"), edit_project_path(@project))
- add_to_breadcrumbs(s_("ProjectService|Integrations"), project_settings_integrations_path(@project))
= render 'deprecated_message' if @service.deprecation_message
......
- @content_class = "limit-container-width" unless fluid_layout
- breadcrumb_title _("Integrations Settings")
- breadcrumb_title _('Integration Settings')
- page_title _('Integrations')
= render 'projects/hooks/index'
- if show_webhooks_moved_alert?
.gl-alert.gl-alert-info.js-webhooks-moved-alert.prepend-top-default{ role: 'alert', data: { feature_id: UserCalloutsHelper::WEBHOOKS_MOVED, dismiss_endpoint: user_callouts_path } }
= sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
%button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') }
= sprite_icon('close', size: 16, css_class: 'gl-icon')
.gl-alert-body
= _('Webhooks have moved. They can now be found under the Settings menu.')
.gl-alert-actions
= link_to _('Go to Webhooks'), project_hooks_path(@project), class: 'btn gl-alert-action btn-info new-gl-button'
= render 'projects/services/index'
......@@ -15,62 +15,62 @@
= form.check_box :push_events, class: 'form-check-input'
= form.label :push_events, class: 'list-label form-check-label ml-1' do
%strong Push events
%p.light.ml-1
= form.text_field :push_events_branch_filter, class: 'form-control', placeholder: 'Branch name or wildcard pattern to trigger on (leave blank for all)'
%p.text-muted.ml-1
This URL will be triggered by a push to the repository
= form.text_field :push_events_branch_filter, class: 'form-control', placeholder: 'Branch name or wildcard pattern to trigger on (leave blank for all)'
%li
= form.check_box :tag_push_events, class: 'form-check-input'
= form.label :tag_push_events, class: 'list-label form-check-label ml-1' do
%strong Tag push events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when a new tag is pushed to the repository
%li
= form.check_box :note_events, class: 'form-check-input'
= form.label :note_events, class: 'list-label form-check-label ml-1' do
%strong Comments
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when someone adds a comment
%li
= form.check_box :confidential_note_events, class: 'form-check-input'
= form.label :confidential_note_events, class: 'list-label form-check-label ml-1' do
%strong Confidential Comments
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when someone adds a comment on a confidential issue
%li
= form.check_box :issues_events, class: 'form-check-input'
= form.label :issues_events, class: 'list-label form-check-label ml-1' do
%strong Issues events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when an issue is created/updated/merged
%li
= form.check_box :confidential_issues_events, class: 'form-check-input'
= form.label :confidential_issues_events, class: 'list-label form-check-label ml-1' do
%strong Confidential Issues events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when a confidential issue is created/updated/merged
%li
= form.check_box :merge_requests_events, class: 'form-check-input'
= form.label :merge_requests_events, class: 'list-label form-check-label ml-1' do
%strong Merge request events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when a merge request is created/updated/merged
%li
= form.check_box :job_events, class: 'form-check-input'
= form.label :job_events, class: 'list-label form-check-label ml-1' do
%strong Job events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when the job status changes
%li
= form.check_box :pipeline_events, class: 'form-check-input'
= form.label :pipeline_events, class: 'list-label form-check-label ml-1' do
%strong Pipeline events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when the pipeline status changes
%li
= form.check_box :wiki_page_events, class: 'form-check-input'
= form.label :wiki_page_events, class: 'list-label form-check-label ml-1' do
%strong Wiki Page events
%p.light.ml-1
%p.text-muted.ml-1
This URL will be triggered when a wiki page is created/updated
.form-group
= form.label :enable_ssl_verification, 'SSL verification', class: 'label-bold checkbox'
......
---
title: Decouple Webhooks from Integrations within Project > Settings
merge_request: 23136
author:
type: changed
......@@ -45,7 +45,7 @@ They are available **per project** for GitLab Community Edition,
and **per project and per group** for **GitLab Enterprise Edition**.
Navigate to the webhooks page by going to your project's
**Settings ➔ Integrations**.
**Settings ➔ Webhooks**.
## Maximum number of webhooks (per tier)
......
......@@ -6997,9 +6997,6 @@ msgstr ""
msgid "Edit Pipeline Schedule %{id}"
msgstr ""
msgid "Edit Project Hook"
msgstr ""
msgid "Edit Release"
msgstr ""
......@@ -9451,6 +9448,9 @@ msgstr ""
msgid "Go to %{link_to_google_takeout}."
msgstr ""
msgid "Go to Webhooks"
msgstr ""
msgid "Go to commits"
msgstr ""
......@@ -10607,10 +10607,13 @@ msgstr ""
msgid "Instance license"
msgstr ""
msgid "Integration Settings"
msgstr ""
msgid "Integrations"
msgstr ""
msgid "Integrations Settings"
msgid "Integrations allow you to integrate GitLab with other applications"
msgstr ""
msgid "Interested parties can even contribute by pushing commits if they want to."
......@@ -14780,9 +14783,6 @@ msgstr ""
msgid "Project Files"
msgstr ""
msgid "Project Hooks"
msgstr ""
msgid "Project ID"
msgstr ""
......@@ -14945,30 +14945,18 @@ msgstr ""
msgid "ProjectService|Comment will be posted on each event"
msgstr ""
msgid "ProjectService|Integrations"
msgstr ""
msgid "ProjectService|Last edit"
msgstr ""
msgid "ProjectService|Perform common operations on GitLab project: %{project_name}"
msgstr ""
msgid "ProjectService|Project services"
msgstr ""
msgid "ProjectService|Project services allow you to integrate GitLab with other applications"
msgstr ""
msgid "ProjectService|Service"
msgstr ""
msgid "ProjectService|Services"
msgstr ""
msgid "ProjectService|Settings"
msgstr ""
msgid "ProjectService|To set up this service:"
msgstr ""
......@@ -21811,6 +21799,15 @@ msgstr ""
msgid "WebIDE|Merge request"
msgstr ""
msgid "Webhook"
msgstr ""
msgid "Webhook Logs"
msgstr ""
msgid "Webhook Settings"
msgstr ""
msgid "Webhooks"
msgstr ""
......@@ -21820,6 +21817,9 @@ msgstr ""
msgid "Webhooks allow you to trigger a URL if, for example, new code is pushed or a new issue is created. You can configure webhooks to listen for specific events like pushes, issues or merge requests. Group webhooks will apply to all projects in a group, allowing you to standardize webhook functionality across your entire group."
msgstr ""
msgid "Webhooks have moved. They can now be found under the Settings menu."
msgstr ""
msgid "Wednesday"
msgstr ""
......
......@@ -12,12 +12,11 @@ describe Projects::HooksController do
end
describe '#index' do
it 'redirects to settings/integrations page' do
get(:index, params: { namespace_id: project.namespace, project_id: project })
it 'renders index with 200 status code' do
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to redirect_to(
project_settings_integrations_path(project)
)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
end
......
......@@ -88,6 +88,7 @@ describe 'Project navbar' do
_('General'),
_('Members'),
_('Integrations'),
_('Webhooks'),
_('Repository'),
_('CI / CD'),
_('Operations'),
......
......@@ -14,7 +14,7 @@ describe 'User views services' do
end
it 'shows the list of available services' do
expect(page).to have_content('Project services')
expect(page).to have_content('Integrations')
expect(page).to have_content('Campfire')
expect(page).to have_content('HipChat')
expect(page).to have_content('Assembla')
......
......@@ -2,11 +2,10 @@
require 'spec_helper'
describe 'Projects > Settings > Integration settings' do
describe 'Projects > Settings > Webhook Settings' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
let(:integrations_path) { project_settings_integrations_path(project) }
let(:webhooks_path) { project_hooks_path(project) }
before do
sign_in(user)
......@@ -17,7 +16,7 @@ describe 'Projects > Settings > Integration settings' do
let(:role) { :developer }
it 'to be disallowed to view' do
visit integrations_path
visit webhooks_path
expect(page.status_code).to eq(404)
end
......@@ -33,7 +32,7 @@ describe 'Projects > Settings > Integration settings' do
it 'show list of webhooks' do
hook
visit integrations_path
visit webhooks_path
expect(page.status_code).to eq(200)
expect(page).to have_content(hook.url)
......@@ -49,7 +48,7 @@ describe 'Projects > Settings > Integration settings' do
end
it 'create webhook' do
visit integrations_path
visit webhooks_path
fill_in 'hook_url', with: url
check 'Tag push events'
......@@ -68,7 +67,7 @@ describe 'Projects > Settings > Integration settings' do
it 'edit existing webhook' do
hook
visit integrations_path
visit webhooks_path
click_link 'Edit'
fill_in 'hook_url', with: url
......@@ -81,25 +80,25 @@ describe 'Projects > Settings > Integration settings' do
it 'test existing webhook', :js do
WebMock.stub_request(:post, hook.url)
visit integrations_path
visit webhooks_path
find('.hook-test-button.dropdown').click
click_link 'Push events'
expect(current_path).to eq(integrations_path)
expect(current_path).to eq(webhooks_path)
end
context 'delete existing webhook' do
it 'from webhooks list page' do
hook
visit integrations_path
visit webhooks_path
expect { click_link 'Delete' }.to change(ProjectHook, :count).by(-1)
end
it 'from webhook edit page' do
hook
visit integrations_path
visit webhooks_path
click_link 'Edit'
expect { click_link 'Delete' }.to change(ProjectHook, :count).by(-1)
......
......@@ -56,7 +56,7 @@ describe 'profiles/preferences/show' do
expect(rendered).not_to have_sourcegraph_field
end
it 'does not display integrations settings' do
it 'does not display Integration Settings' do
expect(rendered).not_to have_integrations_section
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