From 9a8b5b75d55daaad6421943b09c91a5f1be01b7f Mon Sep 17 00:00:00 2001
From: Zhiyuan Lu <1551755561@qq.com>
Date: Mon, 5 Feb 2024 21:44:29 +0000
Subject: [PATCH] Update MR pipeline page message with permission details

---
 .../pipelines/legacy_pipelines_table_wrapper.vue | 16 ++++++++++++++--
 locale/gitlab.pot                                |  2 +-
 .../legacy_pipelines_table_wrapper_spec.js       |  7 ++++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/app/assets/javascripts/commit/pipelines/legacy_pipelines_table_wrapper.vue b/app/assets/javascripts/commit/pipelines/legacy_pipelines_table_wrapper.vue
index 1954f9f8f35da..13c8dbf101af0 100644
--- a/app/assets/javascripts/commit/pipelines/legacy_pipelines_table_wrapper.vue
+++ b/app/assets/javascripts/commit/pipelines/legacy_pipelines_table_wrapper.vue
@@ -197,7 +197,8 @@ export default {
   i18n: {
     runPipelinePopoverTitle: s__('Pipeline|Run merge request pipeline'),
     runPipelinePopoverDescription: s__(
-      'Pipeline|To run a merge request pipeline, the jobs in the CI/CD configuration file %{linkStart}must be configured%{linkEnd} to run in merge request pipelines.',
+      `Pipeline|To run a merge request pipeline, the jobs in the CI/CD configuration file %{ciDocsLinkStart}must be configured%{ciDocsLinkEnd} to run in merge request pipelines
+      and you must have %{permissionDocsLinkStart}sufficient permissions%{permissionDocsLinkEnd} in the source project.`,
     ),
     runPipelineText: s__('Pipeline|Run pipeline'),
     emptyStateTitle: s__('Pipelines|There are currently no pipelines.'),
@@ -205,6 +206,9 @@ export default {
   mrPipelinesDocsPath: helpPagePath('ci/pipelines/merge_request_pipelines.md', {
     anchor: 'prerequisites',
   }),
+  userPermissionsDocsPath: helpPagePath('user/permissions.md', {
+    anchor: 'gitlab-cicd-permissions',
+  }),
   runPipelinesInTheParentProjectHelpPath: helpPagePath(
     '/ci/pipelines/merge_request_pipelines.html',
     {
@@ -241,7 +245,7 @@ export default {
       >
         <template #description>
           <gl-sprintf :message="$options.i18n.runPipelinePopoverDescription">
-            <template #link="{ content }">
+            <template #ciDocsLink="{ content }">
               <gl-link
                 :href="$options.mrPipelinesDocsPath"
                 target="_blank"
@@ -249,6 +253,14 @@ export default {
                 >{{ content }}</gl-link
               >
             </template>
+            <template #permissionDocsLink="{ content }">
+              <gl-link
+                :href="$options.userPermissionsDocsPath"
+                target="_blank"
+                data-testid="user-permissions-docs-link"
+                >{{ content }}</gl-link
+              >
+            </template>
           </gl-sprintf>
         </template>
 
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index c93aafa99e7be..226603070e3e5 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -36618,7 +36618,7 @@ msgstr ""
 msgid "Pipeline|This pipeline ran on the contents of the merge request's source branch, not the target branch."
 msgstr ""
 
-msgid "Pipeline|To run a merge request pipeline, the jobs in the CI/CD configuration file %{linkStart}must be configured%{linkEnd} to run in merge request pipelines."
+msgid "Pipeline|To run a merge request pipeline, the jobs in the CI/CD configuration file %{ciDocsLinkStart}must be configured%{ciDocsLinkEnd} to run in merge request pipelines and you must have %{permissionDocsLinkStart}sufficient permissions%{permissionDocsLinkEnd} in the source project."
 msgstr ""
 
 msgid "Pipeline|To see the remaining jobs, go to the %{boldStart}Jobs%{boldEnd} tab."
diff --git a/spec/frontend/commit/pipelines/legacy_pipelines_table_wrapper_spec.js b/spec/frontend/commit/pipelines/legacy_pipelines_table_wrapper_spec.js
index d58b139dae35a..0393254c7c1d9 100644
--- a/spec/frontend/commit/pipelines/legacy_pipelines_table_wrapper_spec.js
+++ b/spec/frontend/commit/pipelines/legacy_pipelines_table_wrapper_spec.js
@@ -39,6 +39,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
   const findTableRows = () => wrapper.findAllByTestId('pipeline-table-row');
   const findModal = () => wrapper.findComponent(GlModal);
   const findMrPipelinesDocsLink = () => wrapper.findByTestId('mr-pipelines-docs-link');
+  const findUserPermissionsDocsLink = () => wrapper.findByTestId('user-permissions-docs-link');
   const findPipelinesTable = () => wrapper.findComponent(PipelinesTable);
 
   const createComponent = ({ props = {}, mountFn = mountExtended } = {}) => {
@@ -91,8 +92,12 @@ describe('Pipelines table in Commits and Merge requests', () => {
         expect(findMrPipelinesDocsLink().attributes('href')).toBe(
           '/help/ci/pipelines/merge_request_pipelines.md#prerequisites',
         );
+        expect(findUserPermissionsDocsLink().attributes('href')).toBe(
+          '/help/user/permissions.md#gitlab-cicd-permissions',
+        );
         expect(findEmptyState().text()).toContain(
-          'To run a merge request pipeline, the jobs in the CI/CD configuration file must be configured to run in merge request pipelines.',
+          'To run a merge request pipeline, the jobs in the CI/CD configuration file must be configured to run in merge request pipelines ' +
+            'and you must have sufficient permissions in the source project.',
         );
       });
     });
-- 
GitLab