Skip to content

Added notification message when browser is wrong #2070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ability to change label color in tasks and predefined labels (<https://github.com/opencv/cvat/pull/2014>)
- [Datumaro] Multi-dataset merge (https://github.com/opencv/cvat/pull/1695)
- Link to django admin page from UI (<https://github.com/opencv/cvat/pull/2068>)
- Notification message when users use wrong browser (<https://github.com/opencv/cvat/pull/2070>)

### Changed
- Shape coordinates are rounded to 2 digits in dumped annotations (<https://github.com/opencv/cvat/pull/1970>)
Expand Down
57 changes: 49 additions & 8 deletions cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cvat-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"worker-loader": "^2.0.0"
},
"dependencies": {
"@types/platform": "^1.3.2",
"@types/react": "^16.9.2",
"@types/react-color": "^3.0.2",
"@types/react-dom": "^16.9.0",
Expand All @@ -62,6 +63,7 @@
"dotenv-webpack": "^1.7.0",
"error-stack-parser": "^2.0.6",
"moment": "^2.24.0",
"platform": "^1.3.6",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-color": "^2.18.1",
Expand Down
34 changes: 34 additions & 0 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { withRouter, RouteComponentProps } from 'react-router-dom';
import { GlobalHotKeys, ExtendedKeyMapOptions, configure } from 'react-hotkeys';
import Spin from 'antd/lib/spin';
import Layout from 'antd/lib/layout';
import { Row, Col } from 'antd/lib/grid';
import Text from 'antd/lib/typography/Text';
import notification from 'antd/lib/notification';

import GlobalErrorBoundary from 'components/global-error-boundary/global-error-boundary';
Expand All @@ -23,9 +25,11 @@ import LoginPageContainer from 'containers/login-page/login-page';
import RegisterPageContainer from 'containers/register-page/register-page';
import Header from 'components/header/header';
import { customWaViewHit } from 'utils/enviroment';
import showPlatformNotification, { stopNotifications, platformInfo } from 'utils/platform-checker';

import getCore from 'cvat-core-wrapper';
import { NotificationsState } from 'reducers/interfaces';
import Modal from 'antd/lib/modal';

interface CVATAppProps {
loadFormats: () => void;
Expand Down Expand Up @@ -267,6 +271,36 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
},
};

if (showPlatformNotification()) {
stopNotifications(false);
const info = platformInfo();
Modal.warning({
title: 'Unsupported platform detected',
content: (
<>
<Row>
<Col>
<Text>
{`The browser you are using is ${info.name} ${info.version} based on ${info.engine} .`
+ ' CVAT was tested in the latest versions of Chrome and Firefox.'
+ ' We recommend to use Chrome (or another Chromium based browser)'}
</Text>
</Col>
</Row>
<Row>
<Col>
<Text type='secondary'>
{`The operating system is ${info.os}`}
</Text>
</Col>
</Row>
</>
),
onOk: () => stopNotifications(true),
});
}


if (readyForRender) {
if (user) {
return (
Expand Down
40 changes: 40 additions & 0 deletions cvat-ui/src/utils/platform-checker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

import platform from 'platform';

const engine = platform.layout || 'unknown';
const name = platform.name || 'unknown';
const version = platform.version || 'unknown';
const os = platform.os ? platform.os.toString() : 'unknown';
let platformNotificationShown = window.localStorage.getItem('platformNotiticationShown') !== null;

export function platformInfo(): {
engine: string;
name: string;
version: string;
os: string;
} {
return {
engine,
name,
version,
os,
};
}

export function stopNotifications(saveInStorage: boolean): void {
platformNotificationShown = true;
if (saveInStorage) {
window.localStorage.setItem('platformNotiticationShown', 'shown');
}
}

export default function showPlatformNotification(): boolean {
// Blick is engine of Chrome, Microsoft Edge >= v79
// Gecko is engine of Firefox, supported but works worse than in Chrome (let's show the message)
// WebKit is engine of Apple Safary, not supported
const unsupportedPlatform = !['Blink'].includes(engine);
return unsupportedPlatform && !platformNotificationShown;
}