Skip to content

Commit 7fdc0d6

Browse files
honzikecJan Kaiser
andauthored
[angular-ngrx-scss] pulls tab (#1942)
* wip: PRs * wip: PRs * fix: use search api, fix tests * fix: adjusted regex * fix: try to prevent regex backtracking * fix: avoid regex, properly paginate * fix: restore deleted code * refactor: remove code duplications * fix: add clear filters button and resolve lint warnings * fix: use nullish coalescing operator instead of logical or * fix: replace logical or with nullish coalescing operator --------- Co-authored-by: Jan Kaiser <honzikec@Jan-MacBook-Air.local>
1 parent ae1a799 commit 7fdc0d6

42 files changed

Lines changed: 600 additions & 319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

angular-ngrx-scss/projects/prism/src/lib/types/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type TokenEnv = {
1414
tokens: Array<string | PrismToken>;
1515
};
1616

17-
export type StyleObj = { [klass: string]: any } | null;
17+
export type StyleObj = { [klass: string]: unknown } | null;
1818

1919
export type LineInputProps = {
2020
style?: StyleObj;

angular-ngrx-scss/projects/prism/src/lib/utils/normalize-tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const normalizeTokens = (tokens: Array<PrismToken | string>): Token[][] => {
4040

4141
let i = 0;
4242
let stackIndex = 0;
43-
let currentLine: any[] = [];
43+
let currentLine: Token[] = [];
4444

4545
const acc = [currentLine];
4646

angular-ngrx-scss/src/app/file-viewer/file-explorer/file-explorer.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<div class="container grid grid-cols-12 subpage">
33
<section class="col-span-9 col-sm-span-12">
44
<app-file-explorer-nav
5-
[owner]="owner"
6-
[name]="repoName"
5+
[owner]="repo.ownerName"
6+
[name]="repo.repoName"
77
[branch]="repo.activeBranch"
8-
[path]="path"
9-
[showCrumbs]="!!path"
8+
[path]="repo.path"
9+
[showCrumbs]="!!repo.path"
1010
></app-file-explorer-nav>
1111

1212
<app-file-explorer-container
1313
[repoPage]="repo.tree"
1414
[branch]="repo.activeBranch"
15-
[owner]="owner"
16-
[name]="repoName"
15+
[owner]="repo.ownerName"
16+
[name]="repo.repoName"
1717
></app-file-explorer-container>
1818
</section>
1919

angular-ngrx-scss/src/app/file-viewer/file-explorer/file-explorer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
22
import { Store } from '@ngrx/store';
33
import { ActivatedRoute } from '@angular/router';
44
import {
5-
fetchRepository,
65
RepoContents,
6+
fetchRepository,
77
selectedRepository,
88
} from '../../state/repository';
99
import { map, takeWhile, tap } from 'rxjs';
Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
import { HttpHeaders, HttpResponse } from '@angular/common/http';
2+
import { PullRequest } from '../repository/services/repository.interfaces';
13
import {
24
ISSUE_STATE,
35
PullRequestAPIResponse,
4-
PullRequestItemAPIResponse,
56
IssueLabel,
6-
RepoPullRequests,
77
} from '../state/repository';
88

99
export const generatePullRequestAPIResponseFixture = (
1010
state: ISSUE_STATE = 'open',
11-
): PullRequestAPIResponse => {
11+
): HttpResponse<PullRequestAPIResponse> => {
1212
const closedDate = new Date(2022, 2, 1).toISOString();
13-
return {
13+
const body = {
1414
incomplete_results: false,
1515
total_count: 1,
1616
items: [
@@ -37,30 +37,18 @@ export const generatePullRequestAPIResponseFixture = (
3737
} as IssueLabel,
3838
],
3939
comments: 305,
40-
} as PullRequestItemAPIResponse,
40+
} as unknown as PullRequest,
4141
],
4242
};
43-
};
44-
45-
const prObject = generatePullRequestAPIResponseFixture().items[0];
4643

47-
export const pullRequestFixture: RepoPullRequests = {
48-
totalCount: 1,
49-
pullRequests: [
50-
{
51-
id: prObject.id,
52-
login: prObject.user.login,
53-
title: prObject.title,
54-
number: prObject.number,
55-
state: prObject.state,
56-
closedAt: prObject.closed_at ? new Date(prObject.closed_at) : null,
57-
mergedAt: prObject.pull_request.merged_at
58-
? new Date(prObject.pull_request.merged_at)
59-
: null,
60-
createdAt: new Date(prObject.created_at),
61-
labels: prObject.labels,
62-
commentCount: prObject.comments,
63-
labelCount: prObject.labels.length,
64-
},
65-
],
44+
return {
45+
headers: new HttpHeaders(),
46+
status: 200,
47+
statusText: 'OK',
48+
ok: true,
49+
type: 4,
50+
url: 'https://api.github.com/search/issues?q=repo:thisdot/open-source/issues+type:pr+state:open',
51+
clone: jasmine.createSpy('clone'),
52+
body,
53+
};
6654
};

angular-ngrx-scss/src/app/issues/components/issues-header/issues-header.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<div class="container" *ngIf="hasFilters$ | async">
2+
<app-clear-filters-button (clearFilters)="clearFilters()"
3+
>Clear current search query, filters, and sorts</app-clear-filters-button
4+
>
5+
</div>
6+
17
<div class="filters-container">
28
<div class="issue-status">
39
<button [ngClass]="{ active: viewState === 'open' }" (click)="selectOpen()">

angular-ngrx-scss/src/app/issues/components/issues-header/issues-header.component.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
flex-direction: column;
99
padding: variables.$padding--l;
1010
background-color: variables.$gray100;
11+
margin-top: functions.rem(14);
12+
border-top-left-radius: variables.$padding;
13+
border-top-right-radius: variables.$padding;
1114

1215
@media (min-width: variables.$md) {
1316
flex-direction: row;

angular-ngrx-scss/src/app/issues/components/issues-header/issues-header.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ISSUE_STATE,
99
RepoIssues,
1010
fetchIssues,
11+
selectHasActiveIssueFilters,
1112
selectLabels,
1213
selectMilestones,
1314
} from 'src/app/state/repository';
@@ -22,6 +23,8 @@ export class IssuesHeaderComponent {
2223

2324
@Input() repoName!: string;
2425

26+
hasFilters$ = this.store.select(selectHasActiveIssueFilters);
27+
2528
filterParams: { labels?: string; milestone?: string; sort: Sort } = {
2629
sort: 'created',
2730
};
@@ -82,6 +85,11 @@ export class IssuesHeaderComponent {
8285
this.refetchIssues();
8386
}
8487

88+
clearFilters() {
89+
this.filterParams = { sort: 'created' };
90+
this.refetchIssues();
91+
}
92+
8593
private refetchIssues() {
8694
this.store.dispatch(
8795
fetchIssues({

angular-ngrx-scss/src/app/issues/components/issues.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="container issues-container">
1+
<div class="container">
22
<app-issues-header
33
[viewState]="viewState"
44
[openIssues]="openIssues$ | async"
@@ -7,6 +7,8 @@
77
[repoName]="repoName"
88
(viewStateChange)="viewStateChange($event)"
99
></app-issues-header>
10+
</div>
11+
<div class="container issues-container">
1012
<app-issues-list
1113
[issues]="
1214
viewState === 'open' ? (openIssues$ | async) : (closedIssues$ | async)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@use 'variables';
2+
@use 'functions';
23

34
.issues-container {
4-
border-radius: variables.$padding;
5+
border-bottom-left-radius: variables.$padding;
6+
border-bottom-right-radius: variables.$padding;
57
border: 1px solid variables.$gray200;
6-
margin: 1rem auto;
8+
margin-bottom: functions.rem(14);
79
}

0 commit comments

Comments
 (0)