Skip to content

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

Move texts to frontend

Oliver Günther637b1f807c72
diff --git a/modules/github_integration/config/locales/en.yml b/modules/github_integration/config/locales/en.yml
index a1a035e9a59..e540b39366c 100644
--- a/modules/github_integration/config/locales/en.yml
+++ b/modules/github_integration/config/locales/en.yml
@@ -30,19 +30,3 @@ en:
project_module_github: "GitHub"
permission_show_github_content: "Show GitHub content"
- github_integration:
- pull_request_opened_comment: >
- **PR Opened:** Pull request %{pr_number} [%{pr_title}](%{pr_url}) for [%{repository}](%{repository_url})
- has been opened by [%{github_user}](%{github_user_url}).
- pull_request_closed_comment: >
- **PR Closed:** Pull request %{pr_number} [%{pr_title}](%{pr_url}) for [%{repository}](%{repository_url})
- has been closed by [%{github_user}](%{github_user_url}).
- pull_request_merged_comment: >
- **PR Merged:** Pull request %{pr_number} [%{pr_title}](%{pr_url}) for [%{repository}](%{repository_url})
- has been merged by [%{github_user}](%{github_user_url}).
- pull_request_referenced_comment: >
- **Referenced in PR:** [%{github_user}](%{github_user_url}) referenced this work package in
- Pull request %{pr_number} [%{pr_title}](%{pr_url}) on [%{repository}](%{repository_url}).
- pull_request_ready_for_review_comment: >
- **PR Ready for Review:** Pull request %{pr_number} [%{pr_title}](%{pr_url}) for [%{repository}](%{repository_url})
- was marked as ready for review by [%{github_user}](%{github_user_url}).
diff --git a/modules/github_integration/frontend/module/pull-request/pull-request-macro.component.ts b/modules/github_integration/frontend/module/pull-request/pull-request-macro.component.ts
index 9dc2b093d8b..e05266dc6bf 100644
--- a/modules/github_integration/frontend/module/pull-request/pull-request-macro.component.ts
+++ b/modules/github_integration/frontend/module/pull-request/pull-request-macro.component.ts
@@ -42,6 +42,8 @@ import { Observable } from 'rxjs';
export const githubPullRequestMacroSelector = 'macro.github_pull_request';
+export type PullRequestState = 'opened'|'closed'|'referenced'|'ready_for_review'|'merged'|'draft';
+
@Component({
selector: githubPullRequestMacroSelector,
templateUrl: './pull-request-macro.component.html',
@@ -53,6 +55,8 @@ export const githubPullRequestMacroSelector = 'macro.github_pull_request';
export class PullRequestMacroComponent implements OnInit {
@Input() pullRequestId:string;
+ @Input() pullRequestState:PullRequestState;
+
pullRequest$:Observable<IGithubPullRequest>;
constructor(
diff --git a/modules/github_integration/frontend/module/pull-request/pull-request-state.component.html b/modules/github_integration/frontend/module/pull-request/pull-request-state.component.html
new file mode 100644
index 00000000000..4b788cb54c0
--- /dev/null
+++ b/modules/github_integration/frontend/module/pull-request/pull-request-state.component.html
@@ -0,0 +1,68 @@
+<a
+ class='op-pull-request--link'
+ [href]="pullRequest.htmlUrl"
+ target="blank"
+ [textContent]="pullRequest.repository + '#' + pullRequest.number"
+></a>
+
+<div
+ class='op-pull-request--title'
+ [textContent]="pullRequest.title"
+></div>
+
+<div class="op-pull-request--info">
+ {{ text.label_created_by }}
+ <img
+ *ngIf="pullRequest._embedded.githubUser"
+ alt='PR author avatar'
+ class='op-pull-request--avatar op-avatar op-avatar_mini'
+ [src]="pullRequest._embedded.githubUser.avatarUrl"
+ />
+ <span class='op-pull-request--user'>
+ <a
+ *ngIf="pullRequest._embedded.githubUser"
+ [href]="pullRequest._embedded.githubUser.htmlUrl"
+ [textContent]="pullRequest._embedded.githubUser.login"
+ ></a>.
+ </span>
+
+ <span class='op-pull-request--date'>
+ {{ text.label_last_updated_on }}
+ <op-date-time [dateTimeValue]="pullRequest.githubUpdatedAt"></op-date-time>
+ </span>.
+</div>
+
+<span class='op-pull-request--state' [ngClass]="'op-pull-request--state_' + state">
+ <op-icon icon-classes="button--icon icon-merge-branch"></op-icon>
+ {{state}}
+</span>
+
+<span class="op-pull-request--checks-label"
+ *ngIf="pullRequest._embedded.checkRuns?.length"
+ [textContent]="text.label_actions"
+></span>
+
+<ul
+ *ngIf="pullRequest._embedded.checkRuns?.length"
+ [attr.aria-label]="text.label_actions"
+ class='op-pull-request--checks'
+>
+ <li class='op-pr-check' *ngFor="let checkRun of pullRequest._embedded.checkRuns">
+ <span class='op-pr-check--state-icon' [ngClass]="'op-pr-check--state-icon_' + checkRunState(checkRun)">
+ <op-icon icon-classes="icon-{{ checkRunStateIcon(checkRun) }}"
+ [icon-title]="checkRunStateText(checkRun)"></op-icon>
+ </span>
+ <span class='op-pr-check--avatar'><img alt='app owner avatar' [src]="checkRun.appOwnerAvatarUrl"/></span>
+
+ <span class='op-pr-check--info'>
+ <span class='op-pr-check--name' [textContent]="checkRun.name"></span>
+ <span class='op-pr-check--state' [textContent]="checkRunStateText(checkRun)"></span>
+ </span>
+
+ <span class='op-pr-check--details'>
+ <a [href]="checkRun.detailsUrl">
+ {{ text.label_details }}
+ </a>
+ </span>
+ </li>
+</ul>
diff --git a/modules/github_integration/frontend/module/pull-request/pull-request-state.component.sass b/modules/github_integration/frontend/module/pull-request/pull-request-state.component.sass
new file mode 100644
index 00000000000..af93ca99cdf
--- /dev/null
+++ b/modules/github_integration/frontend/module/pull-request/pull-request-state.component.sass
@@ -0,0 +1,103 @@
+//-- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2023 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See COPYRIGHT and LICENSE files for more details.
+//++
+
+@import "helpers"
+
+:host,
+.op-pull-request
+ display: grid
+ grid-template-columns: auto 1fr auto auto
+ grid-template-areas: "link link link link" "title title title state" "info info info info" "checks-label checks-label checks-label checks-label" "checks checks checks checks"
+ margin-bottom: 11px
+ padding-bottom: 11px
+ border-bottom: 1px solid #dddddd
+
+ &:last-child
+ border-bottom: none
+
+ &--title
+ @include text-shortener
+ font-weight: bold
+ grid-area: title
+ // have the same line height as the status "button" next to it
+ line-height: 32px
+ margin-right: 20px
+
+ &--avatar
+ grid-area: info
+
+ &--info
+ display: block
+ grid-area: info
+ margin-bottom: 3px
+ font-size: 0.9rem
+ grid-area: info
+ color: var(--gray-dark)
+ // The mini avatar is much higher than the text line. Compensate it.
+ margin-top: -4px
+
+ &--date
+ grid-area: info
+
+ &--link
+ grid-area: link
+ margin-top: 6px
+ font-size: 0.9rem
+
+ &--state
+ grid-area: state
+ display: inline-block
+ padding: 8px 11px
+ border-radius: 16px
+ border: 1px solid #fff
+ color: #fff
+ font-size: 0.9rem
+ text-transform: capitalize
+
+ &_draft
+ background-color: #6a737d
+
+ &_open
+ background-color: #28a745
+
+ &_merged
+ background-color: #6f42c1
+
+ &_closed
+ background-color: #d73a49
+
+ &--checks-label
+ grid-area: checks-label
+ margin-top: 12px
+ font-size: 0.9rem
+ font-weight: bold
+
+ &--checks
+ margin-top: 12px
+ margin-left: 0
+ grid-area: checks
diff --git a/modules/github_integration/frontend/module/pull-request/pull-request-state.component.ts b/modules/github_integration/frontend/module/pull-request/pull-request-state.component.ts
new file mode 100644
index 00000000000..e69de29bb2d