Skip to content

Commit a3b6d0f

Browse files
authored
Merge pull request #215 from opentripplanner/dev
Release - Hide the Save Trip Button if no user is logged in.
2 parents f6994a9 + 9e98f86 commit a3b6d0f

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

Diff for: lib/components/narrative/default/default-itinerary.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default class DefaultItinerary extends NarrativeItinerary {
2121
itinerary,
2222
LegIcon,
2323
setActiveLeg,
24-
setActiveStep
24+
setActiveStep,
25+
user
2526
} = this.props
2627
return (
2728
<div className={`option default-itin${active ? ' active' : ''}`}>
@@ -32,7 +33,10 @@ export default class DefaultItinerary extends NarrativeItinerary {
3233
<span className='title'>Itinerary {index + 1}</span>{' '}
3334
<span className='duration pull-right'>{formatDuration(itinerary.duration)}</span>{' '}
3435
<span className='arrivalTime'>{formatTime(itinerary.startTime)}{formatTime(itinerary.endTime)}</span>
35-
<span className='pull-right'><LinkButton to='/savetrip'>Save</LinkButton></span>{' '}
36+
{user && (<>
37+
<span className='pull-right'><LinkButton to='/savetrip'>Save</LinkButton></span>{' '}
38+
</>
39+
)}
3640
<ItinerarySummary itinerary={itinerary} LegIcon={LegIcon} />
3741
</button>
3842
{(active || expanded) &&

Diff for: lib/components/narrative/itinerary-carousel.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ItineraryCarousel extends Component {
5050
}
5151

5252
render () {
53-
const { activeItinerary, itineraries, itineraryClass, hideHeader, pending } = this.props
53+
const { activeItinerary, itineraries, itineraryClass, hideHeader, pending, user } = this.props
5454
if (pending) return <Loading small />
5555
if (!itineraries) return null
5656

@@ -61,6 +61,7 @@ class ItineraryCarousel extends Component {
6161
key: index,
6262
expanded: this.props.expanded,
6363
onClick: this._onItineraryClick,
64+
user,
6465
...this.props
6566
})
6667
})
@@ -112,7 +113,8 @@ const mapStateToProps = (state, ownProps) => {
112113
activeLeg: activeSearch && activeSearch.activeLeg,
113114
activeStep: activeSearch && activeSearch.activeStep,
114115
companies: state.otp.currentQuery.companies,
115-
timeFormat: coreUtils.time.getTimeFormat(state.otp.config)
116+
timeFormat: coreUtils.time.getTimeFormat(state.otp.config),
117+
user: state.user.loggedInUser
116118
}
117119
}
118120

Diff for: lib/components/narrative/line-itin/line-itinerary.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export default class LineItinerary extends NarrativeItinerary {
5454
onClick,
5555
setActiveLeg,
5656
showRealtimeAnnotation,
57-
timeFormat
57+
timeFormat,
58+
user
5859
} = this.props
5960

6061
if (!itinerary) {
@@ -76,7 +77,9 @@ export default class LineItinerary extends NarrativeItinerary {
7677
timeOptions={timeOptions}
7778
/>
7879

79-
<span className='pull-right'><LinkButton to='/savetrip'>Save this option</LinkButton></span>
80+
{user &&
81+
<span className='pull-right'><LinkButton to='/savetrip'>Save this option</LinkButton></span>
82+
}
8083

8184
{showRealtimeAnnotation && <SimpleRealtimeAnnotation />}
8285
{active || expanded

Diff for: lib/components/narrative/narrative-itineraries.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class NarrativeItineraries extends Component {
4141
itineraries,
4242
itineraryClass,
4343
realtimeEffects,
44-
useRealtime
44+
useRealtime,
45+
user
4546
} = this.props
4647
if (!itineraries) return null
4748

@@ -69,6 +70,7 @@ class NarrativeItineraries extends Component {
6970
key: index,
7071
active: index === activeItinerary,
7172
routingType: 'ITINERARY',
73+
user,
7274
...this.props
7375
})
7476
})}
@@ -95,6 +97,7 @@ const mapStateToProps = (state, ownProps) => {
9597
activeLeg: activeSearch && activeSearch.activeLeg,
9698
activeStep: activeSearch && activeSearch.activeStep,
9799
useRealtime,
100+
user: state.user.loggedInUser,
98101
companies: state.otp.currentQuery.companies
99102
}
100103
}

Diff for: lib/components/narrative/tabbed-itineraries.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class TabbedItineraries extends Component {
4040
itineraryClass,
4141
realtimeEffects,
4242
useRealtime,
43-
timeFormat
43+
timeFormat,
44+
user
4445
} = this.props
4546
if (!itineraries) return null
4647

@@ -123,6 +124,7 @@ class TabbedItineraries extends Component {
123124
active: true,
124125
routingType: 'ITINERARY',
125126
showRealtimeAnnotation,
127+
user,
126128
...this.props
127129
})}
128130

@@ -149,7 +151,8 @@ const mapStateToProps = (state, ownProps) => {
149151
useRealtime,
150152
companies: state.otp.currentQuery.companies,
151153
tnc: state.otp.tnc,
152-
timeFormat: getTimeFormat(state.otp.config)
154+
timeFormat: getTimeFormat(state.otp.config),
155+
user: state.user.loggedInUser
153156
}
154157
}
155158

0 commit comments

Comments
 (0)