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
Closed

check browers list #634

wants to merge 18 commits into from

Conversation

baurine
Copy link
Collaborator

@baurine baurine commented Jun 15, 2020

What did:

  • Show a simple prompt message, which suggests user update browser, in the top of the page if the browser is not compatible with the browserslist

19

Principle: browserslist-useragent-regexp is a utility to compile browserslist query to a RegExp to test browser useragent.

@baurine baurine marked this pull request as draft June 15, 2020 07:04
} else {
text =
'Your browser version is outdated, recommend to use the latest Chrome or Edge to get better experience.'
}
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.

@@ -10,6 +10,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>
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.

@baurine baurine marked this pull request as ready for review June 15, 2020 08:07
@baurine baurine requested a review from breezewish June 15, 2020 08:09
ui/public/checkBrowser.js Outdated Show resolved Hide resolved
ui/public/checkBrowser.js Outdated Show resolved Hide resolved
'您的浏览器版本已过期,推荐使用最新版本的 Chrome 或 Edge 浏览器以便获得更好的体验。'
} 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

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.

}

const content =
'<div style="background: yellow; width: 100%; position: absolute; top: 0; z-index: 4; padding: 8px; text-align: center; transition: top 2s;">' +
Copy link
Member

Choose a reason for hiding this comment

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

Transition needs later browser support and may not work in old browsers (please verify whether it will break things)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So it just has no animation in the old browser, I guess, let me test it.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, if it doesn't break things then it would be great

var text
if (navigator.language.indexOf('zh') === 0) {
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)

}

const content =
'<div style="background: yellow; width: 100%; position: absolute; top: 0; z-index: 4; padding: 8px; text-align: center; transition: top 2s;">' +
Copy link
Member

Choose a reason for hiding this comment

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

How about using red as the background to bring more attractions

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.

I am ok with it, just found some examples which use the yellow background.

image

image

Copy link
Member

Choose a reason for hiding this comment

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

How about two policies:

  • For browsers that functionality will totally break, must not continue, asking user to change browser, like:
    image
  • For browsers that functionality works (but maybe not perfect), display a soft recommendation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Compared following colors (choose from ant design colors):

red:
red

ff4d4f:
#ff4d4f

yellow:
yellow

ffc53d:
#ffc53d

fadb14:
#fadb14

Feel the last one makes me most comfortable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How about two policies:

  • For browsers that functionality will totally break, must not continue, asking user to change browser, like:
    image
  • For browsers that functionality works (but maybe not perfect), display a soft recommendation.

This would be better.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Cool!

@baurine
Copy link
Collaborator Author

baurine commented Jun 16, 2020

Updated logic:

  1. If the browser is not supported by our pages definitely, we show the following static page to ask the user to update their browser. The list of the unsupported browsers is here: https://browserl.ist/?q=dead%2C+IE+11

    企业微信20200616042540

    企业微信20200616042704

  2. If the browser is supported but the version is too old, show a prompt message box to ask the user to upgrade their browser to the latest version as demonstrated above.

shell.task(
'echo "window.__unsupported_browsers__ = $(browserslist-useragent-regexp "dead, IE 11" --allowHigherVersions)" > ./public/unSupportedBrowsers.js'
)
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The generated full list is here: https://browserl.ist/?q=dead%2C+IE+11

Copy link
Member

Choose a reason for hiding this comment

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

It won't work in some old Chrome versions as well. The list needs some tuning..

<div id="root">
<h1 id="title">Please update your browser</h1>
<p id="desc">
Your browser isn't supported anymore. Update it to get the best TiDB
Copy link
Member

Choose a reason for hiding this comment

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

Notice that YouTube will display different messages when current browser is up-to-date while browsing the same page:
image

This avoid confusing when user switched the browser, and copy-paste the URL.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

The current implementation does not work well to meet the demand "For browsers that functionality will totally break, must not continue, asking user to change browser". It is still displaying soft recommendations. For example, we met a client that uses Chrome 5X. For such users, displaying a soft recommendation is not appropriate (and due to the soft color user might even not notified).

How about implementing a simple version first (I think you can open another PR)? The comprehensive implementation requires much more work to do compared to current PR, for example:

  1. Need to test the minimal supported browser version, for example, Chrome 10 definitely won't work. In such case, only displaying a recommendation is not enough.
  2. Need to check implementation against old browsers to see if the notification itself works. For example, IE6. Current implementation might even have problems in IE6 that cannot display the message correctly.
  3. Need to check implementation against our public path prefix feature for those images and the new updateBrowser.html web page. Current code doesn't seem to be compatible with it..
  4. Now this PR uses a simple redirection. It will cause misinformation after user switching to the required browser but copy-paste the URL again.

The simple version only needs to display an attractive & non-recommendation message when the current browser is not in our supported list. It's simply a wording change over your previous commits: recommend to use ... to get better experience --> Some features may not work. Please use Chrome > xxx, Firefox > xxx, Edge > xxx or .....

@AndreMouche
Copy link

/merge

@ti-srebot
Copy link

Sorry @AndreMouche, you don't have permission to trigger auto merge event on this branch. You are not a committer for the related sigs:Dashboard(slack).

@baurine
Copy link
Collaborator Author

baurine commented Jun 22, 2020

I am working on another PR.

@stale
Copy link

stale bot commented Aug 21, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the type/stale label Aug 21, 2020
@stale stale bot closed this Aug 28, 2020
@SabaPing SabaPing deleted the check-browser-list branch April 3, 2023 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants