This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show issue and comments on hover Closes #241
- Loading branch information
1 parent
27764bf
commit ae9606c
Showing
11 changed files
with
411 additions
and
227 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Response } from '../client'; | ||
import { Issue, IssueComment } from '../issue'; | ||
import { GitHub, Issue as IssueStruct } from './index'; | ||
import { GithubRepository } from './repository'; | ||
import { GithubUser } from './user'; | ||
|
||
export class GithubIssue implements Issue { | ||
|
||
private client: GitHub; | ||
private repository: GithubRepository; | ||
private struct: IssueStruct; | ||
|
||
public get number(): number { | ||
return this.struct.number; | ||
} | ||
|
||
public get title(): string { | ||
return this.struct.title; | ||
} | ||
|
||
public get url(): string { | ||
return this.struct.html_url; | ||
} | ||
|
||
public get body(): string { | ||
return this.struct.body; | ||
} | ||
|
||
constructor(client: GitHub, repository: GithubRepository, struct: IssueStruct) { | ||
this.client = client; | ||
this.repository = repository; | ||
this.struct = struct; | ||
} | ||
|
||
public async comments(): Promise<Response<IssueComment[]>> { | ||
const response = await this.client.getIssueComments( | ||
this.repository.owner, | ||
this.repository.repository, | ||
this.number | ||
); | ||
return { | ||
body: response.body.map(comment => ({ | ||
body: comment.body, | ||
user: new GithubUser(this.client, comment.user) | ||
})) | ||
}; | ||
} | ||
} |
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
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,47 @@ | ||
import { Response } from '../client'; | ||
import { Issue, IssueComment } from '../issue'; | ||
import { GitLab, Issue as IssueStruct } from './api'; | ||
import { GitLabRepository } from './repository'; | ||
import { GitLabUser } from './user'; | ||
|
||
export class GitLabIssue implements Issue { | ||
|
||
private client: GitLab; | ||
private repository: GitLabRepository; | ||
private struct: IssueStruct; | ||
|
||
public get number(): number { | ||
return this.struct.iid; | ||
} | ||
|
||
public get title(): string { | ||
return this.struct.title; | ||
} | ||
|
||
public get url(): string { | ||
return this.struct.web_url; | ||
} | ||
|
||
public get body(): string { | ||
return this.struct.description; | ||
} | ||
|
||
constructor(client: GitLab, repository: GitLabRepository, struct: IssueStruct) { | ||
this.client = client; | ||
this.repository = repository; | ||
this.struct = struct; | ||
} | ||
|
||
public async comments(): Promise<Response<IssueComment[]>> { | ||
const response = await this.client.getIssueNotes( | ||
encodeURIComponent(this.repository.pathWithNamespace), | ||
this.number | ||
); | ||
return { | ||
body: response.body.map(note => ({ | ||
body: note.body, | ||
user: new GitLabUser(this.client, note.author) | ||
})) | ||
}; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
import { Response } from './client'; | ||
import { User } from './user'; | ||
|
||
export interface Issue { | ||
number: number; | ||
title: string; | ||
url: string; | ||
body: string; | ||
|
||
comments(): Promise<Response<IssueComment[]>>; | ||
} | ||
|
||
export interface IssueComment { | ||
user: User; | ||
body: string; | ||
} |
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