diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/PullRequestLabel.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/PullRequestLabel.java index cc4c1803..28c666e2 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/PullRequestLabel.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/PullRequestLabel.java @@ -3,6 +3,7 @@ import jakarta.persistence.Embeddable; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.NonNull; import lombok.Setter; @Embeddable @@ -10,6 +11,9 @@ @Setter @NoArgsConstructor public class PullRequestLabel { + @NonNull private String name; + + @NonNull private String color; } diff --git a/webapp/src/app/ui/app-issue-card/app-issue-card.component.html b/webapp/src/app/ui/app-issue-card/app-issue-card.component.html new file mode 100644 index 00000000..649a3e24 --- /dev/null +++ b/webapp/src/app/ui/app-issue-card/app-issue-card.component.html @@ -0,0 +1,31 @@ +
+
+ + {{ pullRequest().repository.name }} #{{ pullRequest().number }} on {{ pullRequest().createdAt }} + + + +{{ pullRequest().additions }} + -{{ pullRequest().deletions }} + +
+ +
+ {{ pullRequest().title }} + @if (getMostRecentReview(); as review) { + @if(review.state === 'APPROVED') { + + } @else if(review.state === 'DISMISSED') { + + } @else if (review.state === 'COMMENTED') { + + } @else { + + } + } +
+
+ @for (label of pullRequest().pullRequestLabels; track label.name) { + {{ label.name }} + } +
+
diff --git a/webapp/src/app/ui/app-issue-card/app-issue-card.component.ts b/webapp/src/app/ui/app-issue-card/app-issue-card.component.ts new file mode 100644 index 00000000..75c93950 --- /dev/null +++ b/webapp/src/app/ui/app-issue-card/app-issue-card.component.ts @@ -0,0 +1,30 @@ +import { Component, input } from '@angular/core'; +import { PullRequest, PullRequestReview } from '@app/core/modules/openapi'; +import { NgIcon } from '@ng-icons/core'; +import { octCheck, octComment, octFileDiff, octGitPullRequest, octX } from '@ng-icons/octicons'; + +@Component({ + selector: 'app-issue-card', + templateUrl: './app-issue-card.component.html', + imports: [NgIcon], + standalone: true +}) +export class AppIssueCardComponent { + pullRequest = input.required(); + protected readonly octCheck = octCheck; + protected readonly octX = octX; + protected readonly octComment = octComment; + protected readonly octGitPullRequest = octGitPullRequest; + + getMostRecentReview() { + if (!this.pullRequest() || !this.pullRequest().reviews) { + return null; + } + + return Array.from(this.pullRequest().reviews || []).reduce((latest: PullRequestReview, review: PullRequestReview) => { + return new Date(review.updatedAt || 0) > new Date(latest.updatedAt || 0) ? review : latest; + }); + } + + protected readonly octFileDiff = octFileDiff; +} diff --git a/webapp/src/app/ui/pull-request-widget/pull-request-widget.stories.ts b/webapp/src/app/ui/app-issue-card/app-issue-card.stories.ts similarity index 72% rename from webapp/src/app/ui/pull-request-widget/pull-request-widget.stories.ts rename to webapp/src/app/ui/app-issue-card/app-issue-card.stories.ts index a14e21b3..8e5f0eac 100644 --- a/webapp/src/app/ui/pull-request-widget/pull-request-widget.stories.ts +++ b/webapp/src/app/ui/app-issue-card/app-issue-card.stories.ts @@ -1,16 +1,16 @@ import { Meta, StoryObj } from '@storybook/angular'; -import { PullRequestWidgetComponent } from './pull-request-widget.component'; +import { AppIssueCardComponent } from './app-issue-card.component'; import { PullRequest, PullRequestReview, Repository } from '@app/core/modules/openapi'; -const meta: Meta = { - title: 'Components/PullRequestCard', - component: PullRequestWidgetComponent, +const meta: Meta = { + title: 'UI/AppIssueCard', + component: AppIssueCardComponent, tags: ['autodocs'] // Auto-generate docs if enabled }; export default meta; -type Story = StoryObj; +type Story = StoryObj; const repo: Repository = { name: 'Artemis', @@ -22,10 +22,12 @@ const repo: Repository = { const reviews = new Set([ { - state: 'APPROVED' + state: 'APPROVED', + updatedAt: 'Jan 2' }, { - state: 'CHANGES_REQUESTED' + state: 'CHANGES_REQUESTED', + updatedAt: 'Jan 4' } ]); diff --git a/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.html b/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.html deleted file mode 100644 index a7a46ac2..00000000 --- a/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- {{ pullRequest().repository.name }} #{{ pullRequest().number }} on {{ pullRequest().createdAt }} - - +{{ pullRequest().additions }} - -{{ pullRequest().deletions }} - -
- -
- {{ pullRequest().title }} - @if (pullRequest().reviews) { - ({{ pullRequest().reviews.size }} reviews) - } -
-
- @for (label of pullRequest().pullRequestLabels; track label.name) { - {{ label.name }} - } -
-
diff --git a/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.ts b/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.ts deleted file mode 100644 index 6eac1057..00000000 --- a/webapp/src/app/ui/pull-request-widget/pull-request-widget.component.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Component, input } from '@angular/core'; -import { PullRequest } from '@app/core/modules/openapi'; - -@Component({ - selector: 'app-pull-request-widget', - templateUrl: './pull-request-widget.component.html', - standalone: true -}) -export class PullRequestWidgetComponent { - pullRequest = input.required(); -}