Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

feat(review-board): add review board support #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KattMingMing
Copy link

@KattMingMing KattMingMing commented Aug 24, 2018

This PR changes:

  • Uses codeintellify to add support for Review Board.

Testing plan:

I have tested on:

  • Chrome
  • Firefox
  • Safari
  • Phabricator Bundle

@KattMingMing KattMingMing force-pushed the rb-support branch 2 times, most recently from bd25f06 to f8003b6 Compare August 24, 2018 20:38
import { ReviewBoardRepository } from '../util'

function getRepository(repoID: number): Promise<ReviewBoardRepository> {
return new Promise((resolve, reject) => {

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,
}

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(

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,
}

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', {

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,

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

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

@chrismwendt
Copy link

Here's how to move this PR to https://github.com/sourcegraph/sourcegraph/tree/master/packages/browser-extensions

cd browser-extensions
git format-patch master --stdout > /tmp/patch

cd ../sourcegraph
cat /tmp/patch | git am -3 --directory=packages/browser-extensions/
# and fixup merge conflicts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants