diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-02 15:16:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-02 15:16:59 +0000 |
commit | 6f991190fe4dbb93070b090a9a31d71b25e8101d (patch) | |
tree | 0805552c79613c87d5e99c08f9a588d3cfe6f3c5 /app/services | |
parent | 51d59a3538b97d85ebb46039044d3f498809b55a (diff) | |
download | gitlab-ce-6f991190fe4dbb93070b090a9a31d71b25e8101d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/preview_markdown_service.rb | 2 | ||||
-rw-r--r-- | app/services/quick_actions/interpret_service.rb | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/app/services/preview_markdown_service.rb b/app/services/preview_markdown_service.rb index b3a9beabba5..c8ccbe1465e 100644 --- a/app/services/preview_markdown_service.rb +++ b/app/services/preview_markdown_service.rb @@ -24,7 +24,7 @@ class PreviewMarkdownService < BaseService return text, [] unless quick_action_types.include?(target_type) quick_actions_service = QuickActions::InterpretService.new(project, current_user) - quick_actions_service.explain(text, find_commands_target) + quick_actions_service.explain(text, find_commands_target, keep_actions: params[:render_quick_actions]) end def find_user_references(text) diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb index f1e4dac8835..e1646cbf643 100644 --- a/app/services/quick_actions/interpret_service.rb +++ b/app/services/quick_actions/interpret_service.rb @@ -49,12 +49,13 @@ module QuickActions # Takes a text and interprets the commands that are extracted from it. # Returns the content without commands, and array of changes explained. - def explain(content, quick_action_target) + # `keep_actions: true` will keep the quick actions in the content. + def explain(content, quick_action_target, keep_actions: false) return [content, []] unless current_user.can?(:use_quick_actions) @quick_action_target = quick_action_target - content, commands = extractor.extract_commands(content) + content, commands = extractor(keep_actions).extract_commands(content) commands = explain_commands(commands) [content, commands] end @@ -65,8 +66,8 @@ module QuickActions raise Gitlab::QuickActions::CommandDefinition::ParseError, message end - def extractor - Gitlab::QuickActions::Extractor.new(self.class.command_definitions) + def extractor(keep_actions = false) + Gitlab::QuickActions::Extractor.new(self.class.command_definitions, keep_actions: keep_actions) end # Find users for commands like /assign |