Skip to content
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

check browers list #634

Closed
wants to merge 18 commits into from
17 changes: 15 additions & 2 deletions ui/gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,24 @@ task(
shell.task('yarn react-app-rewired build --library')
)

task('build', series('swagger:generate', 'webpack:build'))
task(
'supportedBrowsers',
shell.task(
'echo "window.__supported_browsers__ = $(browserslist-useragent-regexp --allowHigherVersions)" > ./public/supportedBrowsers.js'
)
)

//////////////////////////

task('build', series('swagger:generate', 'supportedBrowsers', 'webpack:build'))

task('build:library', series('swagger:generate', 'webpack:build:library'))

task(
'dev',
series('swagger:generate', parallel('swagger:watch', 'webpack:dev'))
series(
'swagger:generate',
'supportedBrowsers',
parallel('swagger:watch', 'webpack:dev')
)
)
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@types/webpack-env": "^1.15.2",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-import": "^1.13.0",
"browserslist-useragent-regexp": "^2.1.0",
"customize-cra": "^1.0.0-alpha.0",
"esm": "^3.2.25",
"generate-package-json-webpack-plugin": "^1.0.1",
Expand Down
35 changes: 35 additions & 0 deletions ui/public/checkBrowser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function checkBrowser() {
if (!window.__supported_browsers__.test(navigator.userAgent)) {
var text
if (navigator.language.indexOf('zh') === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE6 ~ 10 even do not support NavigatorLanguage API, and I'm afraid it will be broken in such cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me do some test.

text =
'您的浏览器版本已过期,推荐使用最新版本的 Chrome 或 Edge 浏览器以便获得更好的体验。'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTF8 characters might cause problems in some old browsers I guess, please test it against IE6

Copy link
Collaborator Author

@baurine baurine Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, just know it, 😂 Where can I find an IE6 now... anyway, I will try it, maybe I can test it in IE11 first. (ant design only support IE11 for IEs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note.. AFAIK TiDB Dashboard won't work on IE11 as well

Copy link
Member

@breezewish breezewish Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE6 has a wrong charset detecting strategy https://support.microsoft.com/zh-cn/help/928847/internet-explorer-uses-the-wrong-character-set-when-it-renders-an-html (Honestly I have no ideas how to solve it for now)

} else {
text =
'Your browser version is outdated, recommend to use the latest Chrome or Edge to get better experience.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes the page is simply broken, prefer to avoid the soft "recommend"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also support Firefox

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, how about "latest modern browsers"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modern browser is a word for developers and users don't know what it means precisely. I prefer to explicitly list out our supported browsers

}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do a simple i18n to avoid to use i18next library.

const content = `
<div style="background: yellow;
width: 100%;
position: absolute;
top: 0;
z-index: 4;
padding: 8px;
text-align: center;
transition: top 2s;">
<b>
${text}
<a><span>X</span></a>
</b>
<div>
`
baurine marked this conversation as resolved.
Show resolved Hide resolved
var d = document.createElement('div')
d.innerHTML = content
d.querySelector('a').onclick = function () {
d.querySelector('div').style.top = '-60px'
baurine marked this conversation as resolved.
Show resolved Hide resolved
}
document.body.prepend(d)
}
}

checkBrowser()
2 changes: 2 additions & 0 deletions ui/public/diagnoseReport.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="%PUBLIC_URL%/supportedBrowsers.js"></script>
baurine marked this conversation as resolved.
Show resolved Hide resolved
<script src="%PUBLIC_URL%/checkBrowser.js"></script>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can combine these 2 js together but that needs to use sed. As I know, the sed works differently between macOS and Linux.

<div id="root"></div>
</body>
</html>
2 changes: 2 additions & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="%PUBLIC_URL%/supportedBrowsers.js"></script>
<script src="%PUBLIC_URL%/checkBrowser.js"></script>
<div id="dashboard_page_spinner"></div>
<div id="root"></div>
</body>
Expand Down
1 change: 1 addition & 0 deletions ui/public/supportedBrowsers.js

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

89 changes: 87 additions & 2 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,14 @@
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"

"@babel/runtime-corejs3@^7.9.6":
version "7.10.2"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.10.2.tgz#3511797ddf9a3d6f3ce46b99cc835184817eaa4e"
integrity sha512-+a2M/u7r15o3dV1NEizr9bRi+KUVnrs/qYxF0Z06DAPx/4VCWaz1WA7EcbE+uqGgt39lp5akWGmHsTseIkHkHg==
dependencies:
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"

"@babel/[email protected]":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.9.0.tgz#337eda67401f5b066a6f205a3113d4ac18ba495b"
Expand Down Expand Up @@ -1815,6 +1823,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.9.tgz#79df4ae965fb76d31943b54a6419599307a21394"
integrity sha512-EPZBIGed5gNnfWCiwEIwTE2Jdg4813odnG8iNPMQGrqVxrI+wL68SPtPeCX+ZxGBaA6pKAVc6jaKgP/Q0QzfdQ==

"@types/node@^14.0.4":
version "14.0.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9"
integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==

"@types/parse-json@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
Expand Down Expand Up @@ -2448,6 +2461,11 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"

argue-cli@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/argue-cli/-/argue-cli-1.2.1.tgz#27b2304f86370642ad2dcbb69f00fd728215073f"
integrity sha512-Em3HDMlqiVLNOgXUCYz5NG1mx/44aijsxUOO8elmfvAN4/3ar1S3WPTua7WGhsMbeQm8clOwpDZ09sN7C2FnOg==

aria-query@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-3.0.0.tgz#65b3fcc1ca1155a8c9ae64d6eee297f15d5133cc"
Expand Down Expand Up @@ -3150,6 +3168,19 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"

browserslist-useragent-regexp@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/browserslist-useragent-regexp/-/browserslist-useragent-regexp-2.1.0.tgz#2485686e08ff9699ce298bb8ab4cc6b1bb4da7d3"
integrity sha512-tp2GxiN2g5/5T5TR5VtPc2bUYyHBrvdnoblJlKiF814kB+/U8++Qk8a/znxNVUNHLqEzjyX1Y2X5QmSrXSZJtQ==
dependencies:
"@babel/runtime-corejs3" "^7.9.6"
"@types/node" "^14.0.4"
argue-cli "^1.2.0"
browserslist "^4.5.6"
chalk "^4.0.0"
easy-table "^1.1.1"
useragent "^2.3.0"

[email protected]:
version "4.10.0"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.10.0.tgz#f179737913eaf0d2b98e4926ac1ca6a15cbcc6a9"
Expand All @@ -3160,7 +3191,7 @@ [email protected]:
node-releases "^1.1.52"
pkg-up "^3.1.0"

browserslist@^4.0.0, browserslist@^4.11.1, browserslist@^4.12.0, browserslist@^4.6.2, browserslist@^4.6.4, browserslist@^4.8.5, browserslist@^4.9.1:
browserslist@^4.0.0, browserslist@^4.11.1, browserslist@^4.12.0, browserslist@^4.5.6, browserslist@^4.6.2, browserslist@^4.6.4, browserslist@^4.8.5, browserslist@^4.9.1:
version "4.12.0"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.12.0.tgz#06c6d5715a1ede6c51fc39ff67fd647f740b656d"
integrity sha512-UH2GkcEDSI0k/lRkuDSzFl9ZZ87skSy9w2XAn1MsZnL+4c4rqbBd3e82UWHbYDpztABrPBhZsTEeuxVfHppqDg==
Expand Down Expand Up @@ -3618,6 +3649,11 @@ clone-stats@^1.0.0:
resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680"
integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=

clone@^1.0.2:
version "1.0.4"
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4=

clone@^2.1.1, clone@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
Expand Down Expand Up @@ -4651,6 +4687,13 @@ default-resolution@^2.0.0:
resolved "https://registry.yarnpkg.com/default-resolution/-/default-resolution-2.0.0.tgz#bcb82baa72ad79b426a76732f1a81ad6df26d684"
integrity sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=

defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=
dependencies:
clone "^1.0.2"

define-properties@^1.1.2, define-properties@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1"
Expand Down Expand Up @@ -4937,6 +4980,15 @@ each-props@^1.3.0:
is-plain-object "^2.0.1"
object.defaults "^1.1.0"

easy-table@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/easy-table/-/easy-table-1.1.1.tgz#c1b9b9ad68a017091a1c235e4bcba277540e143f"
integrity sha512-C9Lvm0WFcn2RgxbMnTbXZenMIWcBtkzMr+dWqq/JsVoGFSVUVlPqeOa5LP5kM0I3zoOazFpckOEb2/0LDFfToQ==
dependencies:
ansi-regex "^3.0.0"
optionalDependencies:
wcwidth ">=1.0.1"

ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
Expand Down Expand Up @@ -8450,6 +8502,14 @@ [email protected]:
fault "^1.0.2"
highlight.js "~9.15.0"

[email protected]:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"

lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
Expand Down Expand Up @@ -10663,6 +10723,11 @@ prr@~1.0.1:
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY=

pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=

psl@^1.1.28:
version "1.8.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24"
Expand Down Expand Up @@ -13103,7 +13168,7 @@ tinycolor2@^1.4.1:
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8"
integrity sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g=

tmp@^0.0.33:
tmp@0.0.x, tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
Expand Down Expand Up @@ -13536,6 +13601,14 @@ use@^3.1.0:
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==

useragent@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972"
integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==
dependencies:
lru-cache "4.1.x"
tmp "0.0.x"

util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down Expand Up @@ -13767,6 +13840,13 @@ wbuf@^1.1.0, wbuf@^1.7.3:
dependencies:
minimalistic-assert "^1.0.0"

wcwidth@>=1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=
dependencies:
defaults "^1.0.3"

webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
Expand Down Expand Up @@ -14257,6 +14337,11 @@ y18n@^3.2.0, y18n@^3.2.1:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==

yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=

yallist@^3.0.2:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
Expand Down