grafana/public/app/core/utils/browser.ts
Torkel Ödegaard 8f78b0e7bc
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors

* Added new limit

* Fixed ts issue

* fixed tests

* trying to fix type inference

* Fixing more ts errors

* Revert tsconfig option

* Fix

* Fixed code

* More fixes

* fix tests

* Updated snapshot

* Chore: More ts strict null fixes

* More fixes in some really messed up azure config components

* More fixes, current count: 441

* 419

* More fixes

* Fixed invalid initial state in explore

* Fixing tests

* Fixed tests

* Explore fix

* More fixes

* Progress

* Sub 300

* Now at 218

* Progress

* Update

* Progress

* Updated tests

* at 159

* fixed tests

* Progress

* YAy blow 100! at 94

* 10,9,8,7,6,5,4,3,2,1... lift off

* Fixed tests

* Fixed more type errors

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 12:46:59 +02:00

32 lines
1.1 KiB
TypeScript

// Check to see if browser is not supported by Grafana
export function checkBrowserCompatibility() {
const isIE = navigator.userAgent.indexOf('MSIE') > -1;
const isEdge = navigator.userAgent.indexOf('Edge/') > -1 || navigator.userAgent.indexOf('Edg/') > -1;
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
/* Check for
<= IE11 (Trident 7)
Edge <= 16
Firefox <= 64
Chrome <= 54
*/
const isEdgeVersion = /Edge\/([0-9.]+)/.exec(navigator.userAgent);
if (isIE && parseFloat(/Trident\/([0-9.]+)/.exec(navigator.userAgent)![1]) <= 7) {
return false;
} else if (
isEdge &&
((isEdgeVersion && parseFloat(isEdgeVersion[1]) <= 16) ||
parseFloat(/Edg\/([0-9.]+)/.exec(navigator.userAgent)![1]) <= 16)
) {
return false;
} else if (isFirefox && parseFloat(/Firefox\/([0-9.]+)/.exec(navigator.userAgent)![1]) <= 64) {
return false;
} else if (isChrome && parseFloat(/Chrome\/([0-9.]+)/.exec(navigator.userAgent)![1]) <= 54) {
return false;
}
return true;
}