Skip to content

Commit

Permalink
include version in profile menu
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Sep 24, 2017
1 parent a01b12c commit 6f8bee3
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 5 deletions.
5 changes: 5 additions & 0 deletions pkg/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func main() {
setupTemplates(c)
setupMetrics(c, authManager)

http.HandleFunc("/version", serveVersion)
http.HandleFunc("/", serveUI)

addr := fmt.Sprintf(":%d", port)
Expand Down Expand Up @@ -320,6 +321,10 @@ func requiredInt(c *cli.Context, name string) int {
return value
}

func serveVersion(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(version.Version))
}

func serveUI(w http.ResponseWriter, r *http.Request) {

path := r.URL.Path
Expand Down
10 changes: 10 additions & 0 deletions pkg/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
"target": "https://localhost:8888",
"secure": false,
"ws": true
},
"/version": {
"target": "https://localhost:8888",
"secure": false,
"ws": true
}
},
"_proxy": {
Expand All @@ -118,6 +123,11 @@
"target": "http://localhost:3001",
"secure": false,
"ws": true
},
"/version": {
"target": "http://localhost:3001",
"secure": false,
"ws": true
}
}
}
Binary file removed pkg/ui/public/favicon-original.ico
Binary file not shown.
58 changes: 53 additions & 5 deletions pkg/ui/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Popover from 'material-ui/Popover'
import Menu from 'material-ui/Menu'
import MenuItem from 'material-ui/MenuItem'
import IconLogout from 'material-ui/svg-icons/action/power-settings-new'

import { defaultFetchParams } from '../utils/request-utils'
import Breadcrumbs from './Breadcrumbs'
import ErrorsDialog from './ErrorsDialog'
import Snackbar from 'material-ui/Snackbar'
Expand Down Expand Up @@ -64,6 +64,9 @@ class Header extends React.Component {
}
this.handleLatestErrorRequestClose = this.handleLatestErrorRequestClose.bind(this)
this.handleProfileTouchTap = this.handleProfileTouchTap.bind(this)
this.requestVersion().then(version=> {
this.setState({version: version})
})
}

handleLatestErrorRequestClose = () => {
Expand All @@ -73,7 +76,10 @@ class Header extends React.Component {
}

handleOpen = () => {
this.setState({open: true})
this.setState({
open: true,
profileOpen: false,
})
}

handleClose = () => {
Expand All @@ -89,13 +95,31 @@ class Header extends React.Component {
})
}

requestVersion = async () => {
return fetch('/version', defaultFetchParams
).then(resp => {
if (resp.ok) {
return resp.text()
}
}).then(version => {
let parts = version.split(/-/)
version = parts.slice(0,2).join('-')
if (parts.length > 2) {
version += '+'
}
return version
})
}

handleProfileRequestClose = () => {
this.setState({profileOpen: false})
}

handleLogout = () => {
this.props.invalidateSession()
this.setState({profileOpen: false})
this.setState({
profileOpen: false
})
}

componentWillReceiveProps = (props) => {
Expand Down Expand Up @@ -243,20 +267,44 @@ class Header extends React.Component {
labelStyle={{textTransform: 'none', color: '#9e9e9e'}}
style={{margin: 0}}
/>
{/* buttonStyle={{height: 48}} */}
<Popover
open={this.state.profileOpen}
anchorEl={this.state.profileAnchor}
onRequestClose={this.handleProfileRequestClose}
anchorOrigin={{horizontal: 'right', vertical: 'bottom'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
style={{backgroundColor: 'rgb(33,33,33)'}}
>
<Menu desktop={false}>
<Menu
desktop={false}
className={'profile-menu'}
style={{
background: 'white',
padding: 0,
display: 'block'
}}
>
<MenuItem primaryText="Log out"
leftIcon={<IconLogout/>}
onTouchTap={this.handleLogout}
/>
</Menu>
<div style={{
backgroundImage: `url(${require('../images/logo_small.png')})`,
backgroundSize: '70px 27px',
backgroundPosition: '15px 10px',
backgroundRepeat: 'no-repeat',
backgroundColor: 'rgb(33,33,33)',
height: 55,
borderTop: '3px solid rgb(41, 121, 255)',
textAlign: 'right',
fontSize: 14,
color: 'rgb(180,180,180)',
lineHeight: '60px',
paddingRight: 15,
}}>
{this.state.version}
</div>
</Popover>
</ToolbarGroup>
</Toolbar>
Expand Down
4 changes: 4 additions & 0 deletions pkg/ui/src/components/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ button.profile {
margin-bottom: -4px !important;
}

.profile-menu {
display: block !important;
}

@media screen and (min-width: 1170px) {
.menu-button {
min-width: auto !important;
Expand Down
Binary file added pkg/ui/src/images/logo_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed pkg/ui/src/state/actions/common.js
Empty file.

0 comments on commit 6f8bee3

Please sign in to comment.