diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb index c6c0e7eac901e73fe29daa217d99ee361701b1e2..589dd9b324d2009526012c03b1c70f7ae415d52c 100644 --- a/app/controllers/admin/hooks_controller.rb +++ b/app/controllers/admin/hooks_controller.rb @@ -24,7 +24,7 @@ def hook end def hook_param_names - %i[enable_ssl_verification token url] + %i[enable_ssl_verification name description token url] end def trigger_values diff --git a/app/controllers/concerns/web_hooks/hook_actions.rb b/app/controllers/concerns/web_hooks/hook_actions.rb index 076347922c8173a020ccadecc555d4298b55e6c1..5aeb10dfb878be6ca171b706233b38fe6fbb65ab 100644 --- a/app/controllers/concerns/web_hooks/hook_actions.rb +++ b/app/controllers/concerns/web_hooks/hook_actions.rb @@ -71,7 +71,7 @@ def hook_params end def hook_param_names - %i[enable_ssl_verification token url push_events_branch_filter branch_filter_strategy] + %i[enable_ssl_verification name description token url push_events_branch_filter branch_filter_strategy] end def destroy_hook(hook) diff --git a/app/views/admin/hooks/_form.html.haml b/app/views/admin/hooks/_form.html.haml index 92a664e1ca80ba79f830dad4f829e5fdc39ce967..9f71297c70096290380c5460c20484ee1bc3ca63 100644 --- a/app/views/admin/hooks/_form.html.haml +++ b/app/views/admin/hooks/_form.html.haml @@ -4,6 +4,12 @@ = form.label :url, _('URL'), class: 'label-bold' = form.text_field :url, class: 'form-control gl-form-input' %p.form-text.text-muted= _('URL must be percent-encoded if necessary.') +.form-group + = form.label :name, s_('Webhooks|Name (optional)'), class: 'label-bold' + = form.text_field :name, value: hook.name, class: 'form-control gl-form-input gl-form-input-xl' +.form-group + = form.label :description, s_('Webhooks|Description (optional)'), class: 'label-bold' + = form.text_area :description, value: hook.description, class: 'form-control gl-form-input gl-form-input-xl', rows: 4, maxlength: 2048 .form-group = form.label :token, _('Secret token'), class: 'label-bold' = form.password_field :token, value: hook.masked_token, autocomplete: 'new-password', class: 'form-control gl-form-input gl-max-w-48' diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml index a3dfc6eb0420cdd81719126148e1f9d0c14c17dd..cdef45a041531fc998b0e538d0f919be3a227a0e 100644 --- a/app/views/shared/web_hooks/_form.html.haml +++ b/app/views/shared/web_hooks/_form.html.haml @@ -1,6 +1,12 @@ = form_errors(hook) .js-vue-webhook-form{ data: webhook_form_data(hook) } +.form-group + = form.label :name, s_('Webhooks|Name (optional)'), class: 'label-bold' + = form.text_field :name, value: hook.name, class: 'form-control gl-form-input gl-form-input-xl' +.form-group + = form.label :description, s_('Webhooks|Description (optional)'), class: 'label-bold' + = form.text_area :description, value: hook.description, class: 'form-control gl-form-input gl-form-input-xl', rows: 4, maxlength: 2048 .form-group = form.label :token, s_('Webhooks|Secret token'), class: 'label-bold' = form.password_field :token, value: hook.masked_token, autocomplete: 'new-password', class: 'form-control gl-form-input gl-form-input-xl' diff --git a/app/views/shared/web_hooks/_hook.html.haml b/app/views/shared/web_hooks/_hook.html.haml index a332fd9cce7c66e1ae6a7777e041ef0f8e74cd0a..6c6ff5f7fc859e51aa0b3ef25e82c19cb6c97330 100644 --- a/app/views/shared/web_hooks/_hook.html.haml +++ b/app/views/shared/web_hooks/_hook.html.haml @@ -2,10 +2,13 @@ - sslBadgeText = _('SSL Verification:') + ' ' + sslStatus %li.gl-border-b.gl-last-of-type-border-b-0 - .gl-display-flex.lgl-align-items-center.row.gl-mx-0 - .col-md-8.col-lg-7.gl-px-5 - .light-header.gl-mb-2 + .row.gl-mx-0 + .col-md-8.col-lg-5.gl-px-5 + .light-header.gl-mb-1 + = hook.name + .gl-font-sm = hook.url + - if hook.rate_limited? = gl_badge_tag(_('Disabled'), variant: :danger, size: :sm) - elsif hook.permanently_disabled? @@ -19,7 +22,10 @@ = gl_badge_tag(integration_webhook_event_human_name(trigger), size: :sm) = gl_badge_tag(sslBadgeText, size: :sm) - .col-md-4.col-lg-5.gl-mt-2.gl-px-5.gl-gap-3.gl-display-flex.gl-md-justify-content-end.gl-align-items-baseline + .col-md-2.col-lg-4.gl-px-5.gl-font-sm + = truncate(hook.description, length: 200) + + .col-md-4.col-lg-3.gl-mt-2.gl-px-5.gl-gap-3.gl-display-flex.gl-md-justify-content-end.gl-align-items-baseline = render 'shared/web_hooks/test_button', hook: hook, size: 'small' = render Pajamas::ButtonComponent.new(href: edit_hook_path(hook), size: :small) do = _('Edit') diff --git a/db/migrate/20240116161955_add_name_and_description_to_web_hooks.rb b/db/migrate/20240116161955_add_name_and_description_to_web_hooks.rb new file mode 100644 index 0000000000000000000000000000000000000000..b1360fa4aa2681f73b7a93189c4de5af505083b8 --- /dev/null +++ b/db/migrate/20240116161955_add_name_and_description_to_web_hooks.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddNameAndDescriptionToWebHooks < Gitlab::Database::Migration[2.2] + milestone '16.9' + + # rubocop:disable Migration/AddLimitToTextColumns -- limit is added in + # db/migrate/20240116162201_add_text_limit_to_web_hooks_attributes.rb + def change + add_column :web_hooks, :name, :text + add_column :web_hooks, :description, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20240116162201_add_text_limit_to_web_hooks_attributes.rb b/db/migrate/20240116162201_add_text_limit_to_web_hooks_attributes.rb new file mode 100644 index 0000000000000000000000000000000000000000..3802f1c31f5ff879a0b8df86c5f5242a117f5408 --- /dev/null +++ b/db/migrate/20240116162201_add_text_limit_to_web_hooks_attributes.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddTextLimitToWebHooksAttributes < Gitlab::Database::Migration[2.2] + milestone '16.9' + + disable_ddl_transaction! + + def up + add_text_limit :web_hooks, :name, 255 + add_text_limit :web_hooks, :description, 2048 + end + + def down + remove_text_limit :web_hooks, :name + remove_text_limit :web_hooks, :description + end +end diff --git a/db/schema_migrations/20240116161955 b/db/schema_migrations/20240116161955 new file mode 100644 index 0000000000000000000000000000000000000000..2158e158e8df911e6187caffe077ebb91b478f8f --- /dev/null +++ b/db/schema_migrations/20240116161955 @@ -0,0 +1 @@ +81b09b45a5c6b7c04cbb9fbd112a3f88f64aa837d0229c66c068d0c66efc8c83 \ No newline at end of file diff --git a/db/schema_migrations/20240116162201 b/db/schema_migrations/20240116162201 new file mode 100644 index 0000000000000000000000000000000000000000..51b1472d01a10f9347c34561bbd6fab9a8f0fd58 --- /dev/null +++ b/db/schema_migrations/20240116162201 @@ -0,0 +1 @@ +82f6fe5eef8a794bbbd27919800339c03e416f85598f098eb6eb1c54252e62a3 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index fd741fc3111704f24c8270eeb02b6c4cf01bdae7..b3a9a94fb13a10e7bc7a6a43a0c584d13b3d9e11 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -25805,7 +25805,11 @@ CREATE TABLE web_hooks ( encrypted_url_variables_iv bytea, integration_id integer, branch_filter_strategy smallint DEFAULT 0 NOT NULL, - emoji_events boolean DEFAULT false NOT NULL + emoji_events boolean DEFAULT false NOT NULL, + name text, + description text, + CONSTRAINT check_1e4d5cbdc5 CHECK ((char_length(name) <= 255)), + CONSTRAINT check_23a96ad211 CHECK ((char_length(description) <= 2048)) ); CREATE SEQUENCE web_hooks_id_seq diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 608b930f5c9e3d1c854a29683cd58d84df1404f3..245c56ff8f02442447b48b229e8d07e391b5ca1f 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -55015,6 +55015,9 @@ msgstr "" msgid "Webhooks|Deployment events" msgstr "" +msgid "Webhooks|Description (optional)" +msgstr "" + msgid "Webhooks|Do not show sensitive data such as tokens in the UI." msgstr "" @@ -55054,6 +55057,9 @@ msgstr "" msgid "Webhooks|Must match part of URL" msgstr "" +msgid "Webhooks|Name (optional)" +msgstr "" + msgid "Webhooks|Pipeline events" msgstr ""