2019-01-24 19:15:46 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-01-21 21:01:43 +03:00
|
|
|
import { Badge, Navbar, Nav } from 'reactstrap';
|
2019-01-24 19:15:46 +03:00
|
|
|
|
|
|
|
import LogoMenu from '../shared/LogoMenu';
|
2019-12-17 00:36:58 +03:00
|
|
|
import { getJobsUrl } from '../helpers/url';
|
2019-01-24 19:15:46 +03:00
|
|
|
import Login from '../shared/auth/Login';
|
2019-12-17 00:36:58 +03:00
|
|
|
|
|
|
|
import { resultColorMap } from './helpers';
|
2019-01-24 19:15:46 +03:00
|
|
|
|
|
|
|
export default class Navigation extends React.PureComponent {
|
|
|
|
render() {
|
2020-01-08 02:24:02 +03:00
|
|
|
const {
|
|
|
|
user,
|
|
|
|
setUser,
|
|
|
|
result,
|
|
|
|
notify,
|
|
|
|
repo,
|
|
|
|
revision,
|
|
|
|
children,
|
|
|
|
} = this.props;
|
2019-12-17 00:36:58 +03:00
|
|
|
const overallResult = result ? resultColorMap[result] : 'none';
|
2019-01-24 19:15:46 +03:00
|
|
|
|
|
|
|
return (
|
2020-01-08 02:24:02 +03:00
|
|
|
<React.Fragment>
|
2020-01-21 21:01:43 +03:00
|
|
|
<Navbar dark color="dark" sticky="top" className="flex-column">
|
|
|
|
<Nav className="w-100 justify-content-between">
|
|
|
|
<LogoMenu menuText="Push Health" />
|
|
|
|
<h4>
|
|
|
|
<Badge color={overallResult}>
|
|
|
|
<a
|
|
|
|
href={getJobsUrl({ repo, revision })}
|
|
|
|
className="text-white"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<span title="repository">{repo}</span> -
|
|
|
|
<span title="revision" className="ml-1">
|
|
|
|
{revision}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</Badge>
|
|
|
|
</h4>
|
|
|
|
<Login user={user} setUser={setUser} notify={notify} />
|
|
|
|
</Nav>
|
|
|
|
{children}
|
2020-01-08 02:24:02 +03:00
|
|
|
</Navbar>
|
|
|
|
</React.Fragment>
|
2019-01-24 19:15:46 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Navigation.propTypes = {
|
2020-04-23 22:19:25 +03:00
|
|
|
user: PropTypes.shape({}).isRequired,
|
2019-01-24 19:15:46 +03:00
|
|
|
setUser: PropTypes.func.isRequired,
|
2019-12-17 00:36:58 +03:00
|
|
|
repo: PropTypes.string.isRequired,
|
|
|
|
revision: PropTypes.string.isRequired,
|
2019-06-07 00:39:50 +03:00
|
|
|
notify: PropTypes.func.isRequired,
|
2019-12-17 00:36:58 +03:00
|
|
|
result: PropTypes.string,
|
2020-04-23 22:19:25 +03:00
|
|
|
children: PropTypes.element,
|
2019-12-17 00:36:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
Navigation.defaultProps = {
|
|
|
|
result: '',
|
2020-01-08 02:24:02 +03:00
|
|
|
children: null,
|
2019-01-24 19:15:46 +03:00
|
|
|
};
|