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

add qwant support #654

Merged
merged 2 commits into from
Oct 17, 2018
Merged
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
22 changes: 21 additions & 1 deletion components/brave_new_tab_ui/components/privateTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Page, PageWrapper } from 'brave-ui/features/newTab'

// Components group
import PrivateTab from './privateTab'
import QwantTab from './qwantTab'
import QwantTorTab from './qwantTorTab'
import TorTab from './torTab'

interface Props {
Expand All @@ -18,12 +20,30 @@ interface Props {
}

export default class NewPrivateTab extends React.PureComponent<Props, {}> {
get isQwant () {
// This is not technically accurately describing whether
// the browser has been automatically set to a Qwant region.
// Temporarily we are detecting language here, but we should
// use the same setting logic as used during first-run.
// https://github.com/brave/brave-browser/issues/1632
return navigator.language &&
navigator.language.startsWith('de') ||
navigator.language.startsWith('fr')
}

get currentWindow () {
const { isTor, useAlternativePrivateSearchEngine, onChangePrivateSearchEngine } = this.props
if (isTor) {
if (this.isQwant) {
return <QwantTorTab />
}
return <TorTab />
}

if (this.isQwant) {
return <QwantTab />
}

return (
<PrivateTab
useAlternativePrivateSearchEngine={useAlternativePrivateSearchEngine}
Expand All @@ -35,7 +55,7 @@ export default class NewPrivateTab extends React.PureComponent<Props, {}> {
render () {
const { isTor } = this.props
return (
<Page isPrivate={!isTor}>
<Page isPrivate={!isTor && !this.isQwant}>
Copy link
Member

Choose a reason for hiding this comment

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

It's not private if it's de or fr language?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just to change the background color. I should have written isDefaultPrivate but need to level up my naming game :P

Copy link
Member

Choose a reason for hiding this comment

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

@cezaraugusto that's ok, when things calm down we should look to improve some naming all around the webui's

<PageWrapper>
{this.currentWindow}
</PageWrapper>
Expand Down