@@ -10,11 +10,20 @@ module.exports = React.createClass({
1010 mixins : [ Modal , Navigation ] ,
1111 propTypes : {
1212 planet : React . PropTypes . shape ( {
13- name : React . PropTypes . string
13+ name : React . PropTypes . string ,
14+ Owner : React . PropTypes . shape ( {
15+ id : React . PropTypes . number ,
16+ userType : React . PropTypes . string
17+ } )
1418 } ) ,
1519 search : React . PropTypes . string ,
1620 toggleCodeFilter : React . PropTypes . func ,
17- toggleNoteFilter : React . PropTypes . func
21+ toggleNoteFilter : React . PropTypes . func ,
22+ currentUser : React . PropTypes . shape ( {
23+ id : React . PropTypes . number ,
24+ userType : React . PropTypes . string ,
25+ Teams : React . PropTypes . array
26+ } )
1827 } ,
1928 getInitialState : function ( ) {
2029 return {
@@ -24,6 +33,17 @@ module.exports = React.createClass({
2433 openLaunchModal : function ( ) {
2534 this . openModal ( LaunchModal , { planet : this . props . planet , transitionTo : this . transitionTo } )
2635 } ,
36+ isMyPlanet : function ( ) {
37+ if ( this . props . currentUser == null ) return false
38+ if ( this . props . planet . Owner . userType === 'person' && this . props . planet . Owner . id !== this . props . currentUser . id ) return false
39+ if ( this . props . planet . Owner . userType === 'team' && ! this . props . currentUser . Teams . some ( function ( team ) {
40+ if ( team . id === this . props . planet . Owner . id ) return true
41+ return false
42+ } . bind ( this ) ) ) return false
43+
44+ return true
45+
46+ } ,
2747 render : function ( ) {
2848 var keywords = this . props . search . split ( ' ' )
2949 var usingCodeFilter = keywords . some ( function ( keyword ) {
@@ -37,9 +57,11 @@ module.exports = React.createClass({
3757
3858 return (
3959 < div className = 'PlanetNavigator' >
40- < button onClick = { this . openLaunchModal } className = 'launchButton btn-primary btn-block' >
41- < i className = 'fa fa-rocket fa-fw' /> Launch
42- </ button >
60+ { this . isMyPlanet ( ) ? (
61+ < button onClick = { this . openLaunchModal } className = 'launchButton btn-primary btn-block' >
62+ < i className = 'fa fa-rocket fa-fw' /> Launch
63+ </ button >
64+ ) : null }
4365 < nav className = 'articleFilters' >
4466 < a className = { usingCodeFilter && ! usingNoteFilter ? 'active' : '' } onClick = { this . props . toggleCodeFilter } >
4567 < i className = 'fa fa-code fa-fw' /> Codes
0 commit comments