Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Add support for welcome page #8097

Merged
merged 1 commit into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ let generateBraveManifest = () => {
'referrer': 'no-referrer',
'style-src': '\'self\' \'unsafe-inline\'',
'img-src': '* data: file://*',
'frame-src': '\'self\' https://buy.coinbase.com'
'frame-src': '\'self\' https://buy.coinbase.com https://brave.com'
}

if (process.env.NODE_ENV === 'development') {
Expand Down
21 changes: 21 additions & 0 deletions app/extensions/brave/about-welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<head>
<meta charset="utf-8">
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<link rel="shortcut icon" type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="aboutWelcome"></title>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
<link rel="stylesheet" href="content/styles/defaultStyles.css">
</head>
<body>
<div id="appContainer" class="welcomePage" />
</body>
</html>
27 changes: 27 additions & 0 deletions app/extensions/brave/content/styles/defaultStyles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor Author

@cezaraugusto cezaraugusto Apr 18, 2017

Choose a reason for hiding this comment

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

future refactoring of about pages will benefit from this instead of relying on common.less file so I took advantage of this PR to add it since it's needed anyway for welcome page

* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* Use this file as a normalizer
* to edit webview for about:pages.
*/

html, body {
font-family: "Helvetica Neue", Arial, sans-serif;
font-weight: 400;
margin: 0;
padding: 0;
}

html, body, #appContainer, #appContainer > div {
height: 100%;
}

body {
font-size: 100%;
}

.welcomePage {
overflow: hidden;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here's our hero for double scrollbars

}
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ submit=Submit
settings=Settings
aboutPages=About pages
aboutBrave=About Brave
aboutWelcome=Welcome to Brave
braveInfo=Browse faster and safer with Brave.
releaseNotes=Release Notes
relNotesInfo1=Click
Expand Down
23 changes: 23 additions & 0 deletions app/renderer/about/welcome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')
const {StyleSheet, css} = require('aphrodite/no-important')

class AboutWelcome extends React.Component {
render () {
return <iframe data-test-id='welcomeIframe'
className={css(styles.welcomeIframe)} src='https://brave.com/welcome.html' />
}
}

const styles = StyleSheet.create({
welcomeIframe: {
width: '100%',
height: '100%',
border: 0
}
})

module.exports = <AboutWelcome />
3 changes: 3 additions & 0 deletions js/about/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ switch (getBaseUrl(getSourceAboutUrl(window.location.href))) {
case 'about:contributions':
element = require('./contributionStatement')
break
case 'about:welcome':
element = require('../../app/renderer/about/welcome')
break
}

if (element) {
Expand Down
3 changes: 2 additions & 1 deletion js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ module.exports.aboutUrls = new Immutable.Map({
'about:preferences': module.exports.getBraveExtUrl('about-preferences.html'),
'about:safebrowsing': module.exports.getBraveExtUrl('about-safebrowsing.html'),
'about:styles': module.exports.getBraveExtUrl('about-styles.html'),
'about:contributions': module.exports.getBraveExtUrl('about-contributions.html')
'about:contributions': module.exports.getBraveExtUrl('about-contributions.html'),
'about:welcome': module.exports.getBraveExtUrl('about-welcome.html')
})

module.exports.isIntermediateAboutPage = (location) =>
Expand Down
35 changes: 35 additions & 0 deletions test/unit/about/welcomePageTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to Enzyme instead of Webdriver

* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global describe, before, after, it */

const mockery = require('mockery')
const {shallow} = require('enzyme')
const assert = require('assert')
let AboutWelcome
require('../braveUnit')

describe('AboutWelcome component', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? The test plan says npm run test -- --grep="about:welcome", which does not trigger that.

Copy link
Member

Choose a reason for hiding this comment

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

I just updated it 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks し( ・∀・)/\(・∀・) ///

before(function () {
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
useCleanCache: true
})
AboutWelcome = require('../../../app/renderer/about/welcome')
mockery.registerMock('../../../less/about/common.less', {})
})

after(function () {
mockery.disable()
})

describe('Rendering', function () {
it('renders an iframe', function () {
const wrapper = shallow(
AboutWelcome
)
assert.equal(wrapper.find('[data-test-id="welcomeIframe"]').length, 1)
})
})
})