-
Notifications
You must be signed in to change notification settings - Fork 400
feat: Show compatibility errors in Disco Pane (fix #2095) #2097
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,68 @@ | ||
/* eslint-disable react/no-danger */ | ||
import React, { PropTypes } from 'react'; | ||
import { compose } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { | ||
INCOMPATIBLE_FIREFOX_FOR_IOS, | ||
INCOMPATIBLE_UNDER_MIN_VERSION, | ||
} from 'core/constants'; | ||
import translate from 'core/i18n/translate'; | ||
import { sanitizeHTML } from 'core/utils'; | ||
|
||
import './style.scss'; | ||
|
||
|
||
// Messages in the disco pane are a bit less specific as we don't care about | ||
// non-Firefox clients and the copy space is limited. | ||
export class AddonCompatibilityErrorBase extends React.Component { | ||
static propTypes = { | ||
i18n: PropTypes.object.isRequired, | ||
minVersion: PropTypes.string.isRequired, | ||
reason: PropTypes.string.isRequired, | ||
} | ||
|
||
render() { | ||
const { | ||
i18n, | ||
minVersion, | ||
reason, | ||
} = this.props; | ||
let message; | ||
|
||
if (typeof reason === 'undefined') { | ||
throw new Error('AddonCompatibilityError requires a "reason" prop'); | ||
} | ||
if (typeof minVersion === 'undefined') { | ||
throw new Error('minVersion is required; it cannot be undefined'); | ||
} | ||
|
||
if (reason === INCOMPATIBLE_FIREFOX_FOR_IOS) { | ||
message = i18n.gettext( | ||
'Firefox for iOS does not currently support add-ons.'); | ||
} else if (reason === INCOMPATIBLE_UNDER_MIN_VERSION) { | ||
message = i18n.gettext( | ||
'This add-on does not support your version of Firefox.'); | ||
} else { | ||
// Unknown reasons are fine on the Disco Pane because we don't | ||
// care about non-FF clients. | ||
message = i18n.gettext('This add-on does not support your browser.'); | ||
} | ||
|
||
return ( | ||
<div | ||
className="AddonCompatibilityError" | ||
dangerouslySetInnerHTML={sanitizeHTML(message, ['a'])} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export function mapStateToProps(state) { | ||
return { lang: state.api.lang }; | ||
} | ||
|
||
export default compose( | ||
connect(mapStateToProps), | ||
translate({ withRef: true }), | ||
)(AddonCompatibilityErrorBase); |
This file contains hidden or 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,16 @@ | ||
@import "~ui/css/vars"; | ||
|
||
.AddonCompatibilityError { | ||
background: $report-base-color; | ||
font-size: 12px; | ||
margin: 0; | ||
padding: 5px; | ||
text-align: center; | ||
width: 100%; | ||
|
||
&, | ||
a, | ||
a:link { | ||
color: $white; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -248,7 +248,3 @@ header { | |
} | ||
} | ||
} | ||
|
||
.InstallButton { | ||
@include padding-end(20px); | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other states needed e.g: visited, hover, focus, active etc or are the defaults ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaults are fine, this just keeps the colour white which it will stay for those other states too.