This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Show login window in GH panel #474
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
902cf91
Maintain active tab selection across sessions
9471915
Show basic login view
b488fb8
Make login view a form
b96c7e3
Set up Redux
01d670f
Set up React/Redux dev tools in development
4df8573
Add Repository.githubInfoFromRemote
52e434e
Add GSOS#getRemotes
26ff65d
Add ObserveModel decorator
b34b921
Fix error in GSOS#getRemotes when no remotes exist
6148fd1
Re-throw in GSOS#getRemotes if error isn't due to missing remotes
d45d0cb
Add GSOS#getConfig and #setConfig
7bd5640
Add getConfig and setConfig to Repository
cf03034
Revert "Set up React/Redux dev tools in development"
b96c199
Revert "Set up Redux"
b763c75
Automatically install React dev tools in dev mode
523e59f
Render origin selector if multiple found
54528dd
Add GithubLoginModel
3b35dec
Extract RemtoePropType to prop-types.js
473d49e
Finalize GithubLoginView
674a252
Wire up remote selector -> login
fb46d21
Better wording :art: :memo:
ac65c7d
:fire: parenthetical phrase
9b49af0
:memo: :keyboard:
c32e4e0
Return null instead of <div />
a63209e
Use GSOS#getConfig for #getRemotes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Render origin selector if multiple found
- Loading branch information
There are no files selected for viewing
This file contains hidden or 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,11 +1,116 @@ | ||
| import React from 'react'; | ||
| import {autobind} from 'core-decorators'; | ||
|
|
||
| import GithubLoginView from '../views/github-login-view'; | ||
| import Repository from '../models/repository'; | ||
| import ObserveModel from '../decorators/observe-model'; | ||
|
|
||
| const RemotePropType = React.PropTypes.shape({ | ||
| name: React.PropTypes.string, | ||
| url: React.PropTypes.string, | ||
| info: React.PropTypes.shape({ | ||
| githubRepo: React.PropTypes.bool.isRequired, | ||
| owner: React.PropTypes.string, | ||
| name: React.PropTypes.string, | ||
| }).isRequired, | ||
| }); | ||
|
|
||
| class RemoteSelector extends React.Component { | ||
| static propTypes = { | ||
| remotes: React.PropTypes.arrayOf(RemotePropType).isRequired, | ||
| currentBranch: React.PropTypes.string.isRequired, | ||
| selectRemote: React.PropTypes.func.isRequired, | ||
| } | ||
|
|
||
| render() { | ||
| const {remotes, currentBranch, selectRemote} = this.props; | ||
| return ( | ||
| <div className="github-RemoteSelector"> | ||
| <p> | ||
| This repository has multiple remotes hosted at GitHub.com. | ||
| Select a remote and we'll show you pull requests associated | ||
| with this branch ({currentBranch}). | ||
| </p> | ||
| <ul> | ||
| {remotes.map(remote => ( | ||
| <li key={remote.name}> | ||
| <a href="#" onClick={e => selectRemote(e, remote)}> | ||
| {remote.name} ({remote.info.owner}/{remote.info.name}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh nice ✨ This will save me so many |
||
| </a> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @ObserveModel({ | ||
| getModel: props => props.repository, | ||
| fetchData: async repo => { | ||
| let remotes = await repo.getRemotes(); | ||
| const currentBranch = await repo.getCurrentBranch(); | ||
| const selectedRemote = await repo.getConfig('atomGithub.currentRemote'); | ||
| remotes = remotes.map(({name, url}) => ({name, url, info: Repository.githubInfoFromRemote(url)})) | ||
| .filter(remote => remote.info.githubRepo); | ||
| return {remotes, currentBranch, selectedRemote}; | ||
| }, | ||
| }) | ||
| export default class GithubController extends React.Component { | ||
| static propTypes = { | ||
| repository: React.PropTypes.object, | ||
| remotes: React.PropTypes.arrayOf(RemotePropType.isRequired), | ||
| currentBranch: React.PropTypes.string, | ||
| selectedRemote: React.PropTypes.string, | ||
| } | ||
|
|
||
| static defaultProps = { | ||
| remotes: null, | ||
| currentBranch: '', | ||
| selectedRemote: null, | ||
| } | ||
|
|
||
| render() { | ||
| if (!this.props.remotes) { | ||
| return <div />; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React thing - is this better than returning |
||
| } | ||
|
|
||
| let remote = this.props.remotes.find(r => r.name === this.props.selectedRemote); | ||
| let remotesAvailable = false; | ||
| if (!remote && this.props.remotes.length === 1) { | ||
| remote = this.props.remotes[0]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 for defaulting to a single remote with a prompt. |
||
| } else if (!remote && this.props.remotes.length > 1) { | ||
| remotesAvailable = true; | ||
| } | ||
|
|
||
| return ( | ||
| <GithubLoginView /> | ||
| <div className="github-GithubController"> | ||
| <div className="github-GithubController-content"> | ||
| {remote && <div>Picked remote {remote.info.owner}/{remote.info.name}</div>} | ||
| {!remote && remotesAvailable && | ||
| <RemoteSelector | ||
| remotes={this.props.remotes} | ||
| currentBranch={this.props.currentBranch} | ||
| selectRemote={this.handleRemoteSelect} | ||
| /> | ||
| } | ||
| {!remote && !remotesAvailable && this.renderNoRemotes()} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| renderNoRemotes() { | ||
| return ( | ||
| <div className="github-GithubController-no-remotes"> | ||
| This repository does not have any remotes hosted at GitHub.com. | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| @autobind | ||
| handleRemoteSelect(e, remote) { | ||
| e.preventDefault(); | ||
| this.props.repository.setConfig('atomGithub.currentRemote', remote.name); | ||
| } | ||
| } | ||
This file contains hidden or 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,32 @@ | ||
| .github-GithubController { | ||
| height: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
|
||
| &-content { | ||
| flex: 1; | ||
| } | ||
|
|
||
| &-no-remotes { | ||
| margin: 10px; | ||
| font-size: @font-size * 1.25; | ||
| } | ||
|
|
||
| .github-RemoteSelector { | ||
| font-size: @font-size * 1.25; | ||
|
|
||
| p { | ||
| text-align: center; | ||
| margin: 10px; | ||
| } | ||
|
|
||
| ul { | ||
| list-style: none; | ||
| padding-left: 1em; | ||
| } | ||
|
|
||
| a { | ||
| color: @text-color-info; | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe something like
with the <strong>{currentBranch}</strong> branchto save some parentheticals?(I always wildly overuse parentheticals myself.)