-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create new bad practice components and add to activity dashboard(#199)
- Loading branch information
Showing
7 changed files
with
215 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 36 additions & 52 deletions
88
webapp/src/app/home/activity/activity-dashboard.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
webapp/src/app/user/bad-practice-card/bad-practice-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...src/app/user/pull-request-bad-practice-card/pull-request-bad-practice-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<brn-collapsible> | ||
<button brnCollapsibleTrigger> | ||
<a hlmCard variant="profile"> | ||
<div hlmCardHeader> | ||
<div class="flex justify-between items-center text-sm text-github-muted-foreground"> | ||
<span class="font-medium flex justify-center items-center space-x-1"> | ||
@if (isLoading()) { | ||
<hlm-skeleton class="size-5 bg-green-500/30"></hlm-skeleton> | ||
<hlm-skeleton class="h-4 w-16 lg:w-36"></hlm-skeleton> | ||
} @else { | ||
<ng-icon [svg]="issueIconAndColor().icon" size="18" [class]="'mr-1 ' + issueIconAndColor().color"></ng-icon> | ||
{{ repositoryName() }} #{{ number() }} on {{ displayCreated().format('MMM D') }} | ||
} | ||
</span> | ||
<span class="flex items-center space-x-2"> | ||
@if (isLoading()) { | ||
<hlm-skeleton class="h-4 w-8 bg-green-500/30"></hlm-skeleton> | ||
<hlm-skeleton class="h-4 w-8 bg-destructive/20"></hlm-skeleton> | ||
} @else { | ||
<span class="text-github-success-foreground font-bold">+{{ additions() }}</span> | ||
<span class="text-github-danger-foreground font-bold">-{{ deletions() }}</span> | ||
} | ||
</span> | ||
</div> | ||
<span class="flex justify-between font-medium"> | ||
@if (isLoading()) { | ||
<hlm-skeleton class="h-6 w-3/4"></hlm-skeleton> | ||
} @else { | ||
<div [innerHTML]="displayTitle()" class="truncate"></div> | ||
} | ||
</span> | ||
<span> | ||
<div class="text-left">You have {{ badPractices()?.length }} bad practices in this pull request.</div> | ||
</span> | ||
</div> | ||
@if (!isLoading()) { | ||
<div hlmCardContent class="gap-2 p-0 space-x-0 pl-6 text-left"> | ||
<brn-collapsible-content> | ||
@for (badpractice of badPractices(); track badpractice.title) { | ||
<brn-separator hlmSeparator /> | ||
<app-bad-practice-card [title]="badpractice.title" [description]="badpractice.description"></app-bad-practice-card> | ||
} | ||
</brn-collapsible-content> | ||
</div> | ||
} | ||
</a> | ||
</button> | ||
</brn-collapsible> |
78 changes: 78 additions & 0 deletions
78
...p/src/app/user/pull-request-bad-practice-card/pull-request-bad-practice-card.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Component, computed, input } from '@angular/core'; | ||
import { PullRequestInfo, LabelInfo, PullRequestBadPractice } from '@app/core/modules/openapi'; | ||
import { NgIcon } from '@ng-icons/core'; | ||
import { octCheck, octComment, octFileDiff, octGitPullRequest, octGitPullRequestClosed, octGitPullRequestDraft, octGitMerge, octX } from '@ng-icons/octicons'; | ||
import { HlmCardModule } from '@spartan-ng/ui-card-helm'; | ||
import { HlmSkeletonComponent } from '@spartan-ng/ui-skeleton-helm'; | ||
|
||
import dayjs from 'dayjs'; | ||
import { BadPracticeCardComponent } from '@app/user/bad-practice-card/bad-practice-card.component'; | ||
import { BrnSeparatorComponent } from '@spartan-ng/ui-separator-brain'; | ||
import { HlmSeparatorDirective } from '@spartan-ng/ui-separator-helm'; | ||
import { BrnCollapsibleComponent, BrnCollapsibleContentComponent, BrnCollapsibleTriggerDirective } from '@spartan-ng/ui-collapsible-brain'; | ||
|
||
@Component({ | ||
selector: 'app-pull-request-bad-practice-card', | ||
templateUrl: './pull-request-bad-practice-card.component.html', | ||
imports: [ | ||
NgIcon, | ||
HlmCardModule, | ||
HlmSkeletonComponent, | ||
BadPracticeCardComponent, | ||
BrnSeparatorComponent, | ||
HlmSeparatorDirective, | ||
BrnCollapsibleComponent, | ||
BrnCollapsibleContentComponent, | ||
BrnCollapsibleTriggerDirective | ||
], | ||
standalone: true | ||
}) | ||
export class PullRequestBadPracticeCardComponent { | ||
protected readonly octCheck = octCheck; | ||
protected readonly octX = octX; | ||
protected readonly octComment = octComment; | ||
protected readonly octFileDiff = octFileDiff; | ||
|
||
isLoading = input(false); | ||
class = input(''); | ||
title = input<string>(); | ||
number = input<number>(); | ||
additions = input<number>(); | ||
deletions = input<number>(); | ||
htmlUrl = input<string>(); | ||
repositoryName = input<string>(); | ||
createdAt = input<string>(); | ||
state = input<PullRequestInfo.StateEnum>(); | ||
isDraft = input<boolean>(); | ||
isMerged = input<boolean>(); | ||
pullRequestLabels = input<Array<LabelInfo>>(); | ||
badPractices = input<Array<PullRequestBadPractice>>(); | ||
|
||
displayCreated = computed(() => dayjs(this.createdAt())); | ||
displayTitle = computed(() => (this.title() ?? '').replace(/`([^`]+)`/g, '<code class="textCode">$1</code>')); | ||
|
||
issueIconAndColor = computed(() => { | ||
var icon: string; | ||
var color: string; | ||
|
||
if (this.state() === PullRequestInfo.StateEnum.Open) { | ||
if (this.isDraft()) { | ||
icon = octGitPullRequestDraft; | ||
color = 'text-github-muted-foreground'; | ||
} else { | ||
icon = octGitPullRequest; | ||
color = 'text-github-open-foreground'; | ||
} | ||
} else { | ||
if (this.isMerged()) { | ||
icon = octGitMerge; | ||
color = 'text-github-done-foreground'; | ||
} else { | ||
icon = octGitPullRequestClosed; | ||
color = 'text-github-closed-foreground'; | ||
} | ||
} | ||
|
||
return { icon, color }; | ||
}); | ||
} |
40 changes: 40 additions & 0 deletions
40
webapp/src/app/user/pull-request-bad-practice-card/pull-request-bad-practice-card.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Meta, StoryObj } from '@storybook/angular'; | ||
import { PullRequestBadPracticeCardComponent } from './pull-request-bad-practice-card.component'; | ||
|
||
const meta: Meta<PullRequestBadPracticeCardComponent> = { | ||
component: PullRequestBadPracticeCardComponent, | ||
tags: ['autodocs'] // Auto-generate docs if enabled | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<PullRequestBadPracticeCardComponent>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
title: 'Add feature X', | ||
number: 12, | ||
additions: 10, | ||
deletions: 5, | ||
htmlUrl: 'http://example.com', | ||
state: 'OPEN', | ||
isDraft: false, | ||
isMerged: false, | ||
repositoryName: 'Artemis', | ||
createdAt: '2024-01-01', | ||
pullRequestLabels: [ | ||
{ id: 1, name: 'bug', color: 'f00000' }, | ||
{ id: 2, name: 'enhancement', color: '008000' } | ||
], | ||
badPractices: [ | ||
{ | ||
title: 'Avoid using any type', | ||
description: 'Using the any type defeats the purpose of TypeScript.' | ||
}, | ||
{ | ||
title: 'Unchecked checkbox in description', | ||
description: 'Unchecked checkboxes in the description are not allowed.' | ||
} | ||
] | ||
} | ||
}; |