-
Notifications
You must be signed in to change notification settings - Fork 16
feat(review-board): add review board support #98
base: master
Are you sure you want to change the base?
Conversation
bd25f06
to
f8003b6
Compare
f8003b6
to
590f930
Compare
import { ReviewBoardRepository } from '../util' | ||
|
||
function getRepository(repoID: number): Promise<ReviewBoardRepository> { | ||
return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't use the Promise constructor here, fetch
already returns a Promise.
getCodeElementFromLineNumber: () => null, | ||
getLineNumberFromCodeElement, | ||
getDiffCodePart, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to not have these in a util
file, but in a file dom_functions
like we do for GitHub.
} | ||
const { repository, reviewRequest } = reviewBoardState | ||
getRepositoryFromReviewBoardAPI(repository.id).subscribe(rbRepository => { | ||
resolveRepoPathFromName(rbRepository).subscribe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't nest subscribe, instead use switchMap
repository, | ||
reviewURL, | ||
state, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is your goal here just to clone the object? Why not use { ...page.reviewRequest.attributes }
?
} | ||
|
||
document.dispatchEvent( | ||
new CustomEvent('REVIEW_BOARD_LOADED', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the constant?
detail: { | ||
repository: page.reviewRequest!.attributes.repository, | ||
reviewRequest, | ||
} as ReviewBoardState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting hides errors, it's better to declare it as a variable first.
// Reviewboard has a global RB function on that DOM that we rely on to get ReviewBoard state. | ||
RB: { | ||
PageManager: { | ||
getPage: () => any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be typed instead of any
? It will be hard for people to maintain if they don't know what this returns
Here's how to move this PR to https://github.com/sourcegraph/sourcegraph/tree/master/packages/browser-extensions
|
This PR changes:
Testing plan:
I have tested on: