-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/docker-testing
- Loading branch information
Showing
8 changed files
with
129 additions
and
10 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
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 |
---|---|---|
@@ -1,18 +1,46 @@ | ||
import React from 'react'; | ||
import T from 'i18n-react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import T from 'i18n-react'; | ||
import { connect } from 'react-redux'; | ||
import { loadVersion } from './actions'; | ||
|
||
class Header extends React.Component { | ||
componentDidMount() { | ||
this.props.loadVersion(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<header className="header"> | ||
<div | ||
className="header__logo" | ||
title={'Conquery ' + this.props.version} | ||
/> | ||
<span className="header__spacer" /> | ||
<h1 className="header__headline">{T.translate('headline')}</h1> | ||
{this.props.isDevelopment && <h1 className="header__version">{this.props.version}</h1>} | ||
</header> | ||
); | ||
} | ||
} | ||
|
||
export default Header; | ||
Header.propTypes = { | ||
version: PropTypes.string, | ||
isDevelopment: PropTypes.bool, | ||
loadVersion: PropTypes.func | ||
}; | ||
|
||
const mapStateToProps = (state, ownProps) => { | ||
return { | ||
version: state.version ? state.version.version : '', | ||
isDevelopment: state.version ? state.version.isDevelopment : false, | ||
} | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
loadVersion: () => dispatch(loadVersion()), | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Header); |
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,4 @@ | ||
// api call GET /version | ||
export const LOAD_VERSION_START = "header/LOAD_VERSION_START"; | ||
export const LOAD_VERSION_SUCCESS = "header/LOAD_VERSION_SUCCESS"; | ||
export const LOAD_VERSION_ERROR = "header/LOAD_VERSION_ERROR"; |
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,29 @@ | ||
import { type Dispatch } from 'redux-thunk'; | ||
|
||
import api from '../api'; | ||
import { | ||
defaultError, | ||
defaultSuccess | ||
} from "../common/actions"; | ||
import { | ||
LOAD_VERSION_START, | ||
LOAD_VERSION_SUCCESS, | ||
LOAD_VERSION_ERROR | ||
} from './actionTypes'; | ||
|
||
export const loadVersionStart = () => ({ type: LOAD_VERSION_START }); | ||
export const loadVersionError = (err: any) => defaultError(LOAD_VERSION_ERROR, err); | ||
export const loadVersionSuccess = (res: any) => defaultSuccess(LOAD_VERSION_SUCCESS, res); | ||
|
||
export const loadVersion = () => { | ||
return (dispatch: Dispatch) => { | ||
dispatch(loadVersionStart()); | ||
|
||
return api.getVersion() | ||
.then( | ||
r => { | ||
dispatch(loadVersionSuccess(r)); | ||
}, | ||
e => dispatch(loadVersionError(e))) | ||
} | ||
}; |
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,31 @@ | ||
import { | ||
LOAD_VERSION_START, | ||
LOAD_VERSION_SUCCESS, | ||
LOAD_VERSION_ERROR | ||
} from './actionTypes' | ||
|
||
export type StateType = { | ||
loading: boolean, | ||
development: boolean, | ||
version: string | ||
}; | ||
|
||
const initialState: StateType = {}; | ||
|
||
export const version = (state: StateType = initialState, action: Object): StateType => { | ||
switch (action.type) { | ||
case LOAD_VERSION_START: | ||
return { ...state, loading: true }; | ||
case LOAD_VERSION_SUCCESS: | ||
return { | ||
...state, | ||
loading: false, | ||
isDevelopment: action.payload.data.isDevelopment, | ||
version: action.payload.data.version | ||
}; | ||
case LOAD_VERSION_ERROR: | ||
return { ...state, loading: false, error: action.payload.message }; | ||
default: | ||
return state; | ||
} | ||
}; |
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