Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7303 from capilkey/legacy-browser-support-2
Legacy browser support take 2
- Loading branch information
Showing
13 changed files
with
146 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Gruntfile.js | ||
client/compatibility/* | ||
public/compatibility/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { render } from 'react-dom'; | ||
import Legacy from '/imports/ui/components/legacy/component'; | ||
|
||
// This class is the start of the content loaded on legacy (unsupported) browsers. | ||
// What is included here needs to be minimal and carefully considered because some | ||
// things can't be polyfilled. | ||
|
||
Meteor.startup(() => { | ||
render( | ||
<Legacy />, | ||
document.getElementById('app'), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
bigbluebutton-html5/imports/ui/components/legacy/component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { Component } from 'react'; | ||
import { IntlProvider, FormattedMessage } from 'react-intl'; | ||
import browser from 'browser-detect'; | ||
import './styles.css'; | ||
|
||
// This class is the only component loaded on legacy (unsupported) browsers. | ||
// What is included here needs to be minimal and carefully considered because some | ||
// things can't be polyfilled. | ||
|
||
const FETCHING = 'fetching'; | ||
const FALLBACK = 'fallback'; | ||
const READY = 'ready'; | ||
const supportedBrowsers = ['chrome', 'firefox', 'safari', 'opera', 'edge']; | ||
|
||
export default class Legacy extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
const locale = navigator.languages ? navigator.languages[0] : false | ||
|| navigator.language | ||
|| Meteor.settings.public.app.defaultSettings.application.fallbackLocale; | ||
|
||
const url = `/html5client/locale?locale=${locale}`; | ||
|
||
const that = this; | ||
this.state = { viewState: FETCHING }; | ||
fetch(url) | ||
.then((response) => { | ||
if (!response.ok) { | ||
return Promise.reject(); | ||
} | ||
|
||
return response.json(); | ||
}) | ||
.then(({ messages, normalizedLocale }) => { | ||
const dasherizedLocale = normalizedLocale.replace('_', '-'); | ||
that.setState({ messages, normalizedLocale: dasherizedLocale, viewState: READY }); | ||
}) | ||
.catch(() => { | ||
that.setState({ viewState: FALLBACK }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { messages, normalizedLocale, viewState } = this.state; | ||
const isSupportedBrowser = supportedBrowsers.includes(browser().name); | ||
|
||
switch (viewState) { | ||
case READY: | ||
return ( | ||
<IntlProvider locale={normalizedLocale} messages={messages}> | ||
<p className="browserWarning"> | ||
<FormattedMessage | ||
id={isSupportedBrowser ? 'app.legacy.upgradeBrowser' : 'app.legacy.unsupportedBrowser'} | ||
description="Warning when someone joins with a browser that isnt supported" | ||
values={{ | ||
0: <a href="https://www.google.com/chrome/">Chrome</a>, | ||
1: <a href="https://getfirefox.com">Firefox</a>, | ||
}} | ||
/> | ||
</p> | ||
</IntlProvider> | ||
); | ||
case FALLBACK: | ||
return ( | ||
<p className="browserWarning"> | ||
<span>It looks like you're using a browser that is not fully supported. Please use either </span> | ||
<a href="https://www.google.com/chrome/">Chrome</a> | ||
<span> or </span> | ||
<a href="https://getfirefox.com">Firefox</a> | ||
<span> for full support.</span> | ||
</p> | ||
); | ||
case FETCHING: | ||
default: | ||
return null; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
bigbluebutton-html5/imports/ui/components/legacy/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
The legacy styles can't be scss because it will use Proxy and you can't polyfill it | ||
*/ | ||
|
||
.browserWarning { | ||
border: 5px solid #F3F6F9; | ||
border-radius: 0.5rem; | ||
color: #F3F6F9; | ||
text-align: center; | ||
width:500px; | ||
position:fixed; | ||
left:50%; | ||
margin-left: -250px; | ||
top:50%; | ||
margin-top: -4rem; | ||
font-size: 1.5rem; | ||
padding: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters