diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue index 087b9e59f78f27208021c046fb3b6a458d57b341..96f2970094f9e846ec52cf6ba7ee72e9669a2f5d 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue @@ -9,6 +9,7 @@ import { GlTooltipDirective, GlButton, } from '@gitlab/ui'; +import DuoWorkflowAction from 'ee_component/ai/components/duo_workflow_action.vue'; import SafeHtml from '~/vue_shared/directives/safe_html'; import { s__, n__ } from '~/locale'; import CiIcon from '~/vue_shared/components/ci_icon/ci_icon.vue'; @@ -19,6 +20,7 @@ import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue'; import HelpPopover from '~/vue_shared/components/help_popover.vue'; import HelpIcon from '~/vue_shared/components/help_icon/help_icon.vue'; +import { AGENT_PRIVILEGES } from '~/duo_agent_platform/constants'; import mergeRequestEventTypeQuery from '../queries/merge_request_event_type.query.graphql'; import runPipelineMixin from '../mixins/run_pipeline'; import { @@ -59,12 +61,18 @@ export default { TooltipOnTruncate, HelpPopover, HelpIcon, + DuoWorkflowAction, }, directives: { GlTooltip: GlTooltipDirective, SafeHtml, }, mixins: [runPipelineMixin], + inject: { + mergeRequestPath: { + default: null, + }, + }, props: { pipeline: { type: Object, @@ -194,11 +202,42 @@ export default { return PIPELINE_EVENT_TYPE_MAP[eventTypeName] || { title: '', content: '' }; }, + getPipelinePath() { + if (this.pipeline?.path) { + return `${gon.gitlab_url}${this.pipeline.path}`; + } + return null; + }, + showDuoWorkflowAction() { + return this.hasPipeline && this.status.group === 'failed' && !this.retargeted; + }, + getAdditionalContext() { + return [ + { + Category: 'merge_request', + Content: JSON.stringify({ + url: this.mergeRequestPath, + }), + }, + { + Category: 'pipeline', + Content: JSON.stringify({ + source_branch: this.sourceBranch, + }), + }, + ]; + }, }, errorText: s__( 'Pipeline|Could not retrieve the pipeline status. For troubleshooting steps, read the %{linkStart}documentation%{linkEnd}.', ), monitoringPipelineText: s__('Pipeline|Checking pipeline status.'), + AGENT_PRIVILEGES: [ + AGENT_PRIVILEGES.READ_WRITE_FILES, + AGENT_PRIVILEGES.READ_ONLY_GITLAB, + AGENT_PRIVILEGES.READ_WRITE_GITLAB, + AGENT_PRIVILEGES.USE_GIT, + ], };