fixed nav bar dropdown to stay on channel when view is selected
This commit is contained in:
parent
5f70cdd979
commit
74b6bca16c
3 changed files with 9 additions and 5 deletions
|
@ -1,8 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function NavBarChannelOptionsDropdown ({ channelName, handleSelection, VIEW, LOGOUT }) {
|
function NavBarChannelDropdown ({ channelName, handleSelection, defaultSelection, VIEW, LOGOUT }) {
|
||||||
return (
|
return (
|
||||||
<select type="text" id="nav-bar-channel-select" className="select select--arrow link--nav" onChange={handleSelection}>
|
<select type="text" id="nav-bar-channel-select" className="select select--arrow link--nav" onChange={handleSelection} value={defaultSelection}>
|
||||||
<option id="nav-bar-channel-select-channel-option">{channelName}</option>
|
<option id="nav-bar-channel-select-channel-option">{channelName}</option>
|
||||||
<option value={VIEW}>View</option>
|
<option value={VIEW}>View</option>
|
||||||
<option value={LOGOUT}>Logout</option>
|
<option value={LOGOUT}>Logout</option>
|
||||||
|
@ -10,4 +10,4 @@ function NavBarChannelOptionsDropdown ({ channelName, handleSelection, VIEW, LOG
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NavBarChannelOptionsDropdown;
|
export default NavBarChannelDropdown;
|
||||||
|
|
|
@ -17,6 +17,9 @@ const mapDispatchToProps = dispatch => {
|
||||||
dispatch(updateLoggedInChannel(name, shortId, longId));
|
dispatch(updateLoggedInChannel(name, shortId, longId));
|
||||||
dispatch(updateSelectedChannel(name));
|
dispatch(updateSelectedChannel(name));
|
||||||
},
|
},
|
||||||
|
onChannelLogout: () => {
|
||||||
|
dispatch(updateLoggedInChannel(null, null, null));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ class NavBar extends React.Component {
|
||||||
this.checkForLoggedInUser();
|
this.checkForLoggedInUser();
|
||||||
}
|
}
|
||||||
checkForLoggedInUser () {
|
checkForLoggedInUser () {
|
||||||
// check for whether a channel is already logged in
|
|
||||||
const params = {
|
const params = {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
}
|
}
|
||||||
|
@ -37,7 +36,8 @@ class NavBar extends React.Component {
|
||||||
}
|
}
|
||||||
logoutUser () {
|
logoutUser () {
|
||||||
// send logout request to server
|
// send logout request to server
|
||||||
window.location.href = '/logout'; // NOTE: replace with a call to the server
|
window.location.href = '/logout'; // NOTE: replace with a call to the server that does not redirect
|
||||||
|
// this.props.onChannelLogout()
|
||||||
}
|
}
|
||||||
handleSelection (event) {
|
handleSelection (event) {
|
||||||
console.log('handling selection', event);
|
console.log('handling selection', event);
|
||||||
|
@ -70,6 +70,7 @@ class NavBar extends React.Component {
|
||||||
<NavBarChannelDropdown
|
<NavBarChannelDropdown
|
||||||
channelName={this.props.channelName}
|
channelName={this.props.channelName}
|
||||||
handleSelection={this.handleSelection}
|
handleSelection={this.handleSelection}
|
||||||
|
defaultSelection={this.props.channelName}
|
||||||
VIEW={VIEW}
|
VIEW={VIEW}
|
||||||
LOGOUT={LOGOUT}
|
LOGOUT={LOGOUT}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue