OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#56994] Fix git snippet for GitLab appear broken (although it isn't)
Judith Roth41c699316fca
diff --git a/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts b/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.component.tsindex a8a509b18e9..4e4fa98c927 100644--- a/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts+++ b/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts@@ -67,16 +67,19 @@ export class GitActionsMenuComponent extends OPContextMenuComponent {{id: 'branch',name: this.I18n.t('js.gitlab_integration.tab_header_mr.git_actions.branch_name'),+ textToDisplay: () => this.gitActions.branchName(this.workPackage),textToCopy: () => this.gitActions.branchName(this.workPackage)},{id: 'message',name: this.I18n.t('js.gitlab_integration.tab_header_mr.git_actions.commit_message'),+ textToDisplay: () => this.gitActions.commitMessageDisplayText(this.workPackage),textToCopy: () => this.gitActions.commitMessage(this.workPackage)},{id: 'command',name: this.I18n.t('js.gitlab_integration.tab_header_mr.git_actions.cmd'),+ textToDisplay: () => this.gitActions.gitCommand(this.workPackage),textToCopy: () => this.gitActions.gitCommand(this.workPackage)},];diff --git a/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.template.html b/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.template.htmlindex 0c242188553..aa5f4387185 100644--- a/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.template.html+++ b/modules/gitlab_integration/frontend/module/git-actions-menu/git-actions-menu.template.html@@ -5,7 +5,7 @@<label class="op-form-field--label-wrap"><div class="op-form-field--label">{{ snippet.name }}</div><div class="op-form-field--input">- <input type="text" class="copy-content op-input" readonly="true" [value]="snippet.textToCopy()">+ <input type="text" class="copy-content op-input" readonly="true" [value]="snippet.textToDisplay()"><button class="button copy-button"type="button"[attr.aria-label]="text.copyButtonHelpText"@@ -18,5 +18,3 @@</div></div>--diff --git a/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts b/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.tsindex e4c4eff0543..d79af424e52 100644--- a/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts+++ b/modules/gitlab_integration/frontend/module/git-actions/git-actions.service.ts@@ -81,6 +81,10 @@ ${url}`.replace(/\n\n+/g, '\n\n');}+ public commitMessageDisplayText(workPackage:WorkPackageResource):string {+ return this.commitMessage(workPackage).replace(/\n\n/g, ' ');+ }+public gitCommand(workPackage:WorkPackageResource):string {const branch = this.branchName(workPackage);const commit = this.commitMessage(workPackage);diff --git a/modules/gitlab_integration/frontend/module/typings.d.ts b/modules/gitlab_integration/frontend/module/typings.d.tsindex e3a58215d8f..ab930fee367 100644--- a/modules/gitlab_integration/frontend/module/typings.d.ts+++ b/modules/gitlab_integration/frontend/module/typings.d.ts@@ -33,6 +33,7 @@ import { HalResourceClass } from 'core-app/modules/hal/resources/hal-resource';export interface ISnippet {id:string;name:string;+ textToDisplay:()=>string;textToCopy:()=>string}@@ -96,4 +97,4 @@ export interface IGitlabPipelineResource {ci_details:string[];username:string;commitId:string;-}\ No newline at end of file+}diff --git a/modules/gitlab_integration/spec/features/work_package_gitlab_tab_spec.rb b/modules/gitlab_integration/spec/features/work_package_gitlab_tab_spec.rbindex c9eadb37e70..d8857beb396 100644--- a/modules/gitlab_integration/spec/features/work_package_gitlab_tab_spec.rb+++ b/modules/gitlab_integration/spec/features/work_package_gitlab_tab_spec.rb@@ -78,22 +78,44 @@ RSpec.describe "Open the Gitlab tab", :js dowork_package_page.switch_to_tab(tab: "gitlab")end- it "shows the gitlab tab when the user is allowed to see it" do- work_package_page.visit!- work_package_page.switch_to_tab(tab: "gitlab")+ context "when the user is allowed to see the gitlab tab" do+ before do+ work_package_page.visit!+ work_package_page.switch_to_tab(tab: "gitlab")+ end- tabs.expect_counter(gitlab_tab_element, 2)+ it "shows the issues and merge requests associated with the work package" do+ tabs.expect_counter(gitlab_tab_element, 2)- gitlab_tab.git_actions_menu_button.click- gitlab_tab.git_actions_copy_branch_name_button.click- expect(page).to have_text("Copied!")- expect_clipboard_content("#{work_package.type.name.downcase}/#{work_package.id}-a-test-work_package")+ expect(page).to have_text("A Test Issue title")+ expect(page).to have_text("Open")- expect(page).to have_text("A Test Issue title")- expect(page).to have_text("Open")+ expect(page).to have_text("A Test MR title")+ expect(page).to have_text("Pending")+ end++ it "allows the user to copy the branch name to the clipboard" do+ gitlab_tab.git_actions_menu_button.click+ gitlab_tab.git_actions_copy_branch_name_button.click- expect(page).to have_text("A Test MR title")- expect(page).to have_text("Pending")+ expect(page).to have_text("Copied!")+ expect_clipboard_content("#{work_package.type.name.downcase}/#{work_package.id}-a-test-work_package")+ end++ it "shows a commit message with space between title and link" do+ gitlab_tab.git_actions_menu_button.click++ commit_message_input_text = page.find_field("Commit message").value+ expect(commit_message_input_text).to include("A test work_package http://")+ end++ it "allows the user to copy a commit message with newlines between title and link to the clipboard" do+ gitlab_tab.git_actions_menu_button.click+ gitlab_tab.git_actions_copy_commit_message_button.click++ expect(page).to have_text("Copied!")+ expect_clipboard_content("A test work_package\nhttp://")+ endendcontext "when there are no merge requests or issues" dodiff --git a/modules/gitlab_integration/spec/support/pages/work_package_gitlab_tab.rb b/modules/gitlab_integration/spec/support/pages/work_package_gitlab_tab.rbindex 276201a03c8..9338f1a8c65 100644--- a/modules/gitlab_integration/spec/support/pages/work_package_gitlab_tab.rb+++ b/modules/gitlab_integration/spec/support/pages/work_package_gitlab_tab.rb@@ -50,6 +50,10 @@ module Pagesfind(".git-actions-menu .copy-button:not([disabled])", match: :first)end+ def git_actions_copy_commit_message_button+ all(".git-actions-menu .copy-button:not([disabled])")[1]+ end+def paste_clipboard_contentmeta_key = osx? ? :command : :controlpage.send_keys(meta_key, "v")