Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-28 09:09:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-28 09:09:30 +0300
commit8b7a679616e450608f5d97a09e5287c939477aab (patch)
tree3b951712d6cae1f5bc542ac744ec4182e2ee3b50
parentf72c02a9a54483a73878ebd770eec931ac64c8c2 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/controllers/admin/topics_controller.rb10
-rw-r--r--app/views/admin/topics/_topic.html.haml1
-rw-r--r--app/views/notify/_failed_builds.html.haml8
-rw-r--r--config/routes/admin.rb2
-rw-r--r--doc/user/admin_area/index.md2
-rw-r--r--locale/gitlab.pot11
-rw-r--r--spec/controllers/admin/topics_controller_spec.rb22
7 files changed, 49 insertions, 7 deletions
diff --git a/app/controllers/admin/topics_controller.rb b/app/controllers/admin/topics_controller.rb
index 908313bdb83..b451928e591 100644
--- a/app/controllers/admin/topics_controller.rb
+++ b/app/controllers/admin/topics_controller.rb
@@ -4,7 +4,7 @@ class Admin::TopicsController < Admin::ApplicationController
include SendFileUpload
include PreviewMarkdown
- before_action :topic, only: [:edit, :update]
+ before_action :topic, only: [:edit, :update, :destroy]
feature_category :projects
@@ -37,6 +37,14 @@ class Admin::TopicsController < Admin::ApplicationController
end
end
+ def destroy
+ @topic.destroy!
+
+ redirect_to admin_topics_path,
+ status: :found,
+ notice: _('Topic %{topic_name} was successfully removed.') % { topic_name: @topic.title_or_name }
+ end
+
private
def topic
diff --git a/app/views/admin/topics/_topic.html.haml b/app/views/admin/topics/_topic.html.haml
index 462943263df..869194a21f6 100644
--- a/app/views/admin/topics/_topic.html.haml
+++ b/app/views/admin/topics/_topic.html.haml
@@ -18,3 +18,4 @@
.controls.gl-flex-shrink-0.gl-ml-5
= link_to _('Edit'), edit_admin_topic_path(topic), id: "edit_#{dom_id(topic)}", class: 'btn gl-button btn-default'
+ = link_to _('Remove'), admin_topic_path(topic), aria: { label: _('Remove') }, data: { confirm: _("Are you sure you want to remove %{topic_name}?") % { topic_name: title }, confirm_btn_variant: 'danger' }, method: :delete, class: 'gl-button btn btn-danger'
diff --git a/app/views/notify/_failed_builds.html.haml b/app/views/notify/_failed_builds.html.haml
index afed3c95130..ca589495284 100644
--- a/app/views/notify/_failed_builds.html.haml
+++ b/app/views/notify/_failed_builds.html.haml
@@ -1,12 +1,10 @@
%tr
%td{ colspan: 2, style: "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; color: #333333; font-size: 14px; font-weight: 400; line-height: 1.4; padding: 0 8px 16px; text-align: center;" }
- had
- = failed.size
- failed
- #{'job'.pluralize(failed.size)}.
+ = n_('had %{count} failed job', 'had %{count} failed jobs', failed.size).html_safe % { count: failed.size }
+
%tr.table-warning
%td{ style: "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; border: 1px solid #ededed; border-bottom: 0; border-radius: 4px 4px 0 0; overflow: hidden; background-color: #fdf4f6; color: #d22852; font-size: 14px; line-height: 1.4; text-align: center; padding: 8px 16px;" }
- Failed jobs
+ _('Failed jobs')
%tr.section
%td{ style: "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; padding: 0 16px; border: 1px solid #ededed; border-radius: 4px; overflow: hidden; border-top: 0; border-radius: 0 0 4px 4px;" }
%table.builds{ border: "0", cellpadding: "0", cellspacing: "0", style: "width: 100%; border-collapse: collapse;" }
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index 8148e92d0e5..747197805a8 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -61,7 +61,7 @@ namespace :admin do
end
end
- resources :topics, only: [:index, :new, :create, :edit, :update] do
+ resources :topics, only: [:index, :new, :create, :edit, :update, :destroy] do
resource :avatar, controller: 'topics/avatars', only: [:destroy]
collection do
post :preview_markdown
diff --git a/doc/user/admin_area/index.md b/doc/user/admin_area/index.md
index 295c079c19c..0480757f991 100644
--- a/doc/user/admin_area/index.md
+++ b/doc/user/admin_area/index.md
@@ -270,6 +270,8 @@ To create a new topic, select **New topic**.
To edit a topic, select **Edit** in that topic's row.
+To remove a topic, select **Remove** in that topic's row.
+
To search for topics by name, enter your criteria in the search box. The topic search is case
insensitive and applies partial matching.
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 306bc42ef78..ec8a25a961c 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -4965,6 +4965,9 @@ msgstr ""
msgid "Are you sure you want to remove %{group_name}?"
msgstr ""
+msgid "Are you sure you want to remove %{topic_name}?"
+msgstr ""
+
msgid "Are you sure you want to remove the attachment?"
msgstr ""
@@ -40272,6 +40275,9 @@ msgstr ""
msgid "Topic %{topic_name} was successfully created."
msgstr ""
+msgid "Topic %{topic_name} was successfully removed."
+msgstr ""
+
msgid "Topic avatar"
msgstr ""
@@ -45458,6 +45464,11 @@ msgstr ""
msgid "groups only"
msgstr ""
+msgid "had %{count} failed job"
+msgid_plural "had %{count} failed jobs"
+msgstr[0] ""
+msgstr[1] ""
+
msgid "has already been linked to another vulnerability"
msgstr ""
diff --git a/spec/controllers/admin/topics_controller_spec.rb b/spec/controllers/admin/topics_controller_spec.rb
index 67943525687..ee36d5f1def 100644
--- a/spec/controllers/admin/topics_controller_spec.rb
+++ b/spec/controllers/admin/topics_controller_spec.rb
@@ -151,4 +151,26 @@ RSpec.describe Admin::TopicsController do
end
end
end
+
+ describe 'DELETE #destroy' do
+ it 'removes topic' do
+ delete :destroy, params: { id: topic.id }
+
+ expect(response).to redirect_to(admin_topics_path)
+ expect { topic.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ context 'as a normal user' do
+ before do
+ sign_in(user)
+ end
+
+ it 'renders a 404 error' do
+ delete :destroy, params: { id: topic.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect { topic.reload }.not_to raise_error
+ end
+ end
+ end
end