feat: Add browser info and app version (#1046)

* feat: Add browser info and app version

* quick fix

* lock file

* add build_num

* add screenshot e2e test

* quick test build_num

* revert header

* include i18n texts
This commit is contained in:
Rodrigo Antinarelli authored and Danny Brown committed 2019-10-15 13:09:14 -04:00
1 parent 74f3cbc4b2
commit c217b8bbde
13 files changed
+172 -24

No files matched your search

@@ -0,0 +1,14 @@
{
"Browser": "Browser",
"Build Number": "Build Number",
"Latest Master Commits": "Latest Master Commits",
"More details": "More details",
"Name": "Name",
"OHIF Viewer - About": "OHIF Viewer - About",
"OS": "OS",
"Report an issue": "Report an issue",
"Repository URL": "Repository URL",
"Value": "Value",
"Version Information": "Version Information",
"Visit the forum": "Visit the forum"
}
+2
View File
@@ -1,3 +1,4 @@
import AboutModal from "./AboutModal.json";
import Buttons from "./Buttons.json";
import CineDialog from "./CineDialog.json";
import Common from "./Common.json";
@@ -8,6 +9,7 @@ import UserPreferencesModal from "./UserPreferencesModal.json";
export default {
'en-US': {
AboutModal,
Buttons,
CineDialog,
Common,
@@ -0,0 +1,14 @@
{
"Browser": "Navegador",
"Build Number": "Número da compilação",
"Latest Master Commits": "Últimos Commits na Master",
"More details": "Mais detalhes",
"Name": "Nome",
"OHIF Viewer - About": "OHIF Viewer - Sobre",
"OS": "SO",
"Report an issue": "Informar um problema",
"Repository URL": "URL do Repositório",
"Value": "Valor",
"Version Information": "Informação da Versão",
"Visit the forum": "Visite o fórum"
}
+2
View File
@@ -1,3 +1,4 @@
import AboutModal from "./AboutModal.json";
import Buttons from "./Buttons.json";
import CineDialog from "./CineDialog.json";
import Common from "./Common.json";
@@ -6,6 +7,7 @@ import UserPreferencesModal from "./UserPreferencesModal.json";
export default {
'pt-BR': {
AboutModal,
Buttons,
CineDialog,
Common,
+1
View File
@@ -39,6 +39,7 @@
"dependencies": {
"@babel/runtime": "^7.5.5",
"@ohif/i18n": "^0.2.3",
"browser-detect": "^0.2.28",
"classnames": "2.2.6",
"i18next": "^17.0.3",
"i18next-browser-languagedetector": "^3.0.1",
@@ -1,14 +1,16 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-bootstrap-modal';
import detect from 'browser-detect';
import './AboutModal.styl';
import { withTranslation } from '../../utils/LanguageProvider';
import 'react-bootstrap-modal/lib/css/rbm-patch.css';
// TODO: Is this the only component importing these?
import './../../design/styles/common/modal.styl';
export class AboutModal extends Component {
class AboutModal extends Component {
constructor(props) {
super(props);
}
@@ -18,16 +20,41 @@ export class AboutModal extends Component {
onCancel: PropTypes.func,
};
static itemsPreset = [
{
name: 'Repository URL',
value: 'https://github.com/OHIF/Viewers/',
},
{
name: 'Latest Master Commits',
value: 'https://github.com/OHIF/Viewers/commits/master',
},
];
itemsPreset() {
const { t } = this.props;
const browser = detect();
const capitalize = s =>
s.substr(0, 1).toUpperCase() + s.substr(1).toLowerCase();
return [
{
name: t('Repository URL'),
value: 'https://github.com/OHIF/Viewers/',
link: 'https://github.com/OHIF/Viewers/',
},
{
name: t('Latest Master Commits'),
value: 'https://github.com/OHIF/Viewers/commits/master',
link: 'https://github.com/OHIF/Viewers/commits/master',
},
{
name: 'Version Number',
value: process.env.VERSION_NUMBER,
},
{
name: t('Build Number'),
value: process.env.BUILD_NUM,
},
{
name: t('Browser'),
value: `${capitalize(browser.name)} ${browser.version}`,
},
{
name: t('OS'),
value: browser.os,
},
];
}
static defaultProps = {
isOpen: false,
@@ -38,15 +65,20 @@ export class AboutModal extends Component {
<tr key={item.name}>
<td>{item.name}</td>
<td>
<a target="_blank" href={item.value}>
{item.value}
</a>
{item.link ? (
<a target="_blank" href={item.link}>
{item.value}
</a>
) : (
item.value
)}
</td>
</tr>
);
}
render() {
const { t } = this.props;
return (
<Modal
show={this.props.isOpen}
@@ -58,7 +90,7 @@ export class AboutModal extends Component {
keyboard={false}
>
<Modal.Header closeButton>
<Modal.Title>About</Modal.Title>
<Modal.Title>{t('OHIF Viewer - About')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<div className="btn-group">
@@ -67,34 +99,36 @@ export class AboutModal extends Component {
target="_blank"
href="https://groups.google.com/forum/#!forum/cornerstone-platform"
>
Visit the forum
{t('Visit the forum')}
</a>
{` `}
<a
className="btn btn-default"
target="_blank"
href="https://github.com/OHIF/Viewers/issues"
href="https://github.com/OHIF/Viewers/issues/new/choose"
>
Report an issue
{t('Report an issue')}
</a>
{` `}
<a
className="btn btn-default"
target="_blank"
href="http://ohif.org"
>
More details
{t('More details')}
</a>
</div>
<div>
<h3>Version Information</h3>
<h3>{t('Version Information')}</h3>
<table className="table table-responsive">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>{t('Name')}</th>
<th>{t('Value')}</th>
</tr>
</thead>
<tbody>
{AboutModal.itemsPreset.map(item => this.renderTableRow(item))}
{this.itemsPreset().map(item => this.renderTableRow(item))}
</tbody>
</table>
</div>
@@ -103,3 +137,7 @@ export class AboutModal extends Component {
);
}
}
const connectedComponent = withTranslation('AboutModal')(AboutModal);
export { connectedComponent as AboutModal };
export default connectedComponent;
@@ -12,6 +12,7 @@
z-index: 1050;
-webkit-overflow-scrolling: touch;
outline: 0;
background: rgba(0,0,0,0.5);
.modal-dialog
@@ -4,6 +4,7 @@ describe('OHIFStandaloneViewer', () => {
});
it('loads route with at least 2 rows', () => {
cy.screenshot();
cy.get('#studyListData tr')
.its('length')
.should('be.gt', 2);
@@ -11,6 +11,7 @@ describe('OHIF Study Viewer Page', () => {
});
it('checks if series thumbnails are being displayed', () => {
cy.screenshot();
cy.get('.ThumbnailEntryContainer')
.its('length')
.should('be.gt', 1);
@@ -96,3 +96,27 @@
color: #91b9cd;
margin-right: 1rem;
}
.header-versionInfo {
display: inline-block;
color: black;
background: #9ccef9;
padding: 0px 8px;
border-radius: 16px;
font-size: 12px;
margin-left: 10px;
font-weight: bold;
}
.header-versionInfoHome {
display: block;
color: black;
position: absolute;
bottom: 16px;
right: 0;
background: #9ccef9;
padding: 0px 8px;
border-radius: 16px;
font-size: 12px;
font-weight: bold;
}
@@ -101,6 +101,14 @@ class Header extends Component {
</Link>
)}
<span
className={`${
this.props.home ? 'header-versionInfoHome' : 'header-versionInfo'
}`}
>
v{process.env.VERSION_NUMBER}
</span>
{this.props.children}
{showStudyList && !this.props.home && (