This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,876 additions
and
98 deletions.
There are no files selected for viewing
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,44 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import yubikiri from 'yubikiri'; | ||
|
||
import ObserveModel from '../views/observe-model'; | ||
import LoadingView from '../views/loading-view'; | ||
import CommitDetailController from '../controllers/commit-detail-controller'; | ||
|
||
export default class CommitDetailContainer extends React.Component { | ||
static propTypes = { | ||
repository: PropTypes.object.isRequired, | ||
sha: PropTypes.string.isRequired, | ||
} | ||
|
||
fetchData = repository => { | ||
return yubikiri({ | ||
commit: repository.getCommit(this.props.sha), | ||
currentBranch: repository.getCurrentBranch(), | ||
currentRemote: async query => repository.getRemoteForBranch((await query.currentBranch).getName()), | ||
isCommitPushed: repository.isCommitPushed(this.props.sha), | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<ObserveModel model={this.props.repository} fetchData={this.fetchData}> | ||
{this.renderResult} | ||
</ObserveModel> | ||
); | ||
} | ||
|
||
renderResult = data => { | ||
if (this.props.repository.isLoading() || data === null || !data.commit.isPresent()) { | ||
return <LoadingView />; | ||
} | ||
|
||
return ( | ||
<CommitDetailController | ||
{...data} | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} |
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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import CommitDetailView from '../views/commit-detail-view'; | ||
|
||
export default class CommitDetailController extends React.Component { | ||
static propTypes = { | ||
...CommitDetailView.propTypes, | ||
|
||
commit: PropTypes.object.isRequired, | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
messageCollapsible: this.props.commit.isBodyLong(), | ||
messageOpen: !this.props.commit.isBodyLong(), | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<CommitDetailView | ||
messageCollapsible={this.state.messageCollapsible} | ||
messageOpen={this.state.messageOpen} | ||
toggleMessage={this.toggleMessage} | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
|
||
toggleMessage = () => { | ||
return new Promise(resolve => { | ||
this.setState(prevState => ({messageOpen: !prevState.messageOpen}), resolve); | ||
}); | ||
} | ||
} |
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
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
Oops, something went wrong.