diff --git a/apps/prs/src/app/pr-table/columns/columns.module.ts b/apps/prs/src/app/pr-table/columns/columns.module.ts index cca8b2beb..e743f86a9 100644 --- a/apps/prs/src/app/pr-table/columns/columns.module.ts +++ b/apps/prs/src/app/pr-table/columns/columns.module.ts @@ -3,11 +3,12 @@ import {CommonModule} from '@angular/common'; import {MatTableModule} from '@angular/material/table'; import {SummaryColumn} from './summary/summary.component'; +import {TargetColumn} from './target/target.component'; import {StatusColumn} from './status/status.component'; import {MatIconModule} from '@angular/material/icon'; @NgModule({ - declarations: [SummaryColumn, StatusColumn], + declarations: [SummaryColumn, TargetColumn, StatusColumn], imports: [CommonModule, MatTableModule, MatIconModule], }) export class ColumnsModule {} diff --git a/apps/prs/src/app/pr-table/columns/target/target.component.html b/apps/prs/src/app/pr-table/columns/target/target.component.html new file mode 100644 index 000000000..c4a0a1fb1 --- /dev/null +++ b/apps/prs/src/app/pr-table/columns/target/target.component.html @@ -0,0 +1,4 @@ +Target + + {{getTargetText(row.target)}} + \ No newline at end of file diff --git a/apps/prs/src/app/pr-table/columns/target/target.component.scss b/apps/prs/src/app/pr-table/columns/target/target.component.scss new file mode 100644 index 000000000..dbc8fec1b --- /dev/null +++ b/apps/prs/src/app/pr-table/columns/target/target.component.scss @@ -0,0 +1,11 @@ +.mat-column-target { + max-width: 80px; + + &.mat-header-cell { + justify-content: center; + } + + &.mat-cell { + justify-content: center; + } +} \ No newline at end of file diff --git a/apps/prs/src/app/pr-table/columns/target/target.component.ts b/apps/prs/src/app/pr-table/columns/target/target.component.ts new file mode 100644 index 000000000..d39bf4b36 --- /dev/null +++ b/apps/prs/src/app/pr-table/columns/target/target.component.ts @@ -0,0 +1,44 @@ +import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {BaseColumn} from '../base'; + +/** The targets available, and the text to show in the UI. */ +const Targets = [ + { + label: 'target: patch', + text: 'Patch', + }, + { + label: 'target: minor', + text: 'Minor', + }, + { + label: 'target: major', + text: 'Major', + }, + { + label: 'target: lts', + text: 'LTS', + }, + { + label: 'target: rc', + text: 'RC', + }, + { + label: 'target: feature branch', + text: 'Feature Branch', + }, +]; + +@Component({ + selector: 'target-column', + templateUrl: './target.component.html', + styleUrls: ['./target.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class TargetColumn extends BaseColumn { + name = 'target'; + + getTargetText(target: string) { + return Targets.find((t) => t.label === target)?.text ?? 'No Target'; + } +} diff --git a/apps/prs/src/app/pr-table/pr-table.component.ts b/apps/prs/src/app/pr-table/pr-table.component.ts index 6ebd1761e..fae78674e 100644 --- a/apps/prs/src/app/pr-table/pr-table.component.ts +++ b/apps/prs/src/app/pr-table/pr-table.component.ts @@ -11,6 +11,7 @@ import {PullRequest} from '../../models/pull-request'; import {BaseColumn} from './columns/base'; import {SummaryColumn} from './columns/summary/summary.component'; import {StatusColumn} from './columns/status/status.component'; +import {TargetColumn} from './columns/target/target.component'; @Component({ selector: 'pr-table', @@ -19,7 +20,7 @@ import {StatusColumn} from './columns/status/status.component'; }) export class PrTableComponent implements AfterViewInit { /** The columns used in the PR table. */ - columns: Type[] = [SummaryColumn, StatusColumn]; + columns: Type[] = [SummaryColumn, StatusColumn, TargetColumn]; /** Data source for the table providing the list of pull requests/ */ dataSource: MatTableDataSource = new MatTableDataSource(); /** The table. */ diff --git a/apps/prs/src/models/pull-request.ts b/apps/prs/src/models/pull-request.ts index 6b00cc2b0..d38d54206 100644 --- a/apps/prs/src/models/pull-request.ts +++ b/apps/prs/src/models/pull-request.ts @@ -1,3 +1,11 @@ import {PullRequest as SharedPullRequest} from '../../../shared/models/app-models'; +import {FirestorePullRequest} from '../../../shared/models/pull-request'; -export class PullRequest extends SharedPullRequest {} +export class PullRequest extends SharedPullRequest { + target: string | undefined; + + override async setData(data: FirestorePullRequest) { + await super.setData(data); + this.target = this.labels.find((l) => l?.name?.startsWith('target:'))?.name || ''; + } +} diff --git a/apps/shared/models/pull-request.ts b/apps/shared/models/pull-request.ts index ec6e1533f..5468c851e 100644 --- a/apps/shared/models/pull-request.ts +++ b/apps/shared/models/pull-request.ts @@ -52,7 +52,6 @@ export class PullRequest extends GithubBaseModel { assignees!: User[]; user!: User; commit!: string; - target: undefined | string; // TODO: Determine the status icon via the data from firebase. status = ['pending', 'success', 'failure', 'error'][Math.floor((Math.random() * 100) % 4)];