Skip to content

Commit

Permalink
add support for shields read-only view
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Jul 9, 2019
1 parent bc8b76b commit 0c4c11f
Show file tree
Hide file tree
Showing 22 changed files with 459 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,9 @@
"gotIt": {
"message": "Got it",
"description": "Message for the button that confirms the advanced view"
},
"learnMore": {
"message": "Learn more",
"description": "Message inviting the user to learn more about Shields"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from 'brave-ui/features/shields'

// Group Components
import StaticList from '../overlays/static'
import StaticList from '../overlays/staticOverlay'

// Locale
import { getLocale } from '../../../background/api/localeAPI'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from 'brave-ui/features/shields'

// Group Components
import StaticList from '../overlays/static'
import StaticList from '../overlays/staticOverlay'

// Locale
import { getLocale } from '../../../background/api/localeAPI'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from 'brave-ui/features/shields'

// Group Components
import HTTPSUpgrades from '../overlays/httpsUpgrades'
import HTTPSUpgrades from '../overlays/httpsUpgradesOverlay'

// Locale
import { getLocale } from '../../../background/api/localeAPI'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from 'brave-ui/features/shields'

// Group Components
import NoScript from '../overlays/noScript'
import NoScript from '../overlays/noScriptOverlay'

// Locale
import { getLocale } from '../../../background/api/localeAPI'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../../../types/actions/shieldsPanelActions'

// Components
import NoScriptContent from './noScriptContent'
import NoScriptResourcesList from '../../shared/resourcesBlockedList/noScriptResourcesList'

// Helpers
import {
Expand Down Expand Up @@ -132,7 +132,7 @@ export default class CoreFeature extends React.PureComponent<Props, {}> {
{this.getBlockAllText(true)}
</LinkAction>
</BlockedListItemHeader>
<NoScriptContent
<NoScriptResourcesList
maybeBlock={true}
noScriptInfo={this.generatedNoScriptData}
allowScriptOriginsOnce={this.props.allowScriptOriginsOnce}
Expand Down Expand Up @@ -161,7 +161,7 @@ export default class CoreFeature extends React.PureComponent<Props, {}> {
{this.getBlockAllText(false)}
</LinkAction>
</BlockedListItemHeader>
<NoScriptContent
<NoScriptResourcesList
maybeBlock={false}
noScriptInfo={this.generatedNoScriptData}
allowScriptOriginsOnce={this.props.allowScriptOriginsOnce}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'emptykit.css'
// Components group
import AdvancedView from './advancedView'
import SimpleView from './simpleView'
import ReadOnlyView from './readOnlyView'

// Types
import { Tab, PersistentData } from '../types/state/shieldsPannelState'
Expand Down Expand Up @@ -49,26 +50,46 @@ interface Props {
persistentData: PersistentData
}

export default class Shields extends React.PureComponent<Props, {}> {
interface State {
showReadOnlyView: boolean
}

export default class Shields extends React.PureComponent<Props, State> {
constructor (props: Props) {
super(props)
this.state = { showReadOnlyView: false }
}

toggleReadOnlyView = () => {
this.setState({ showReadOnlyView: !this.state.showReadOnlyView })
}

render () {
const { shieldsPanelTabData, persistentData, actions } = this.props
const { showReadOnlyView } = this.state
if (!shieldsPanelTabData) {
return null
}

return persistentData.advancedView
? (
<AdvancedView
shieldsPanelTabData={shieldsPanelTabData}
persistentData={persistentData}
actions={actions}
/>
) : (
<SimpleView
shieldsPanelTabData={shieldsPanelTabData}
persistentData={persistentData}
actions={actions}
/>
)
? (
<AdvancedView
shieldsPanelTabData={shieldsPanelTabData}
persistentData={persistentData}
actions={actions}
/>
) : showReadOnlyView
? (
<ReadOnlyView
shieldsPanelTabData={shieldsPanelTabData}
toggleReadOnlyView={this.toggleReadOnlyView}
/>
) : (
<SimpleView
shieldsPanelTabData={shieldsPanelTabData}
persistentData={persistentData}
actions={actions}
toggleReadOnlyView={this.toggleReadOnlyView}
/>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* 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/. */

import * as React from 'react'

// Feature-specific components
import {
BlockedInfoRowText,
BlockedInfoRowData,
BlockedInfoRowDetails,
BlockedInfoRowSummary,
ArrowUpIcon,
ArrowDownIcon,
BlockedInfoRowStats,
BlockedListStatic,
dummyData
} from 'brave-ui/features/shields'

// Group components
import StaticResourcesList from '../../shared/resourcesBlockedList/staticResourcesList'

// Helpers
import { getLocale } from '../../../background/api/localeAPI'

interface State {
dummyThirdPartyTrackersBlockedOpen: boolean
}

export default class AdsTrackersControl extends React.PureComponent<{}, State> {
constructor (props: {}) {
super(props)
this.state = { dummyThirdPartyTrackersBlockedOpen: false }
}
onClickFakeThirdPartyTrackersBlocked = () => {
this.setState({ dummyThirdPartyTrackersBlockedOpen: !this.state.dummyThirdPartyTrackersBlockedOpen })
}
render () {
const { dummyThirdPartyTrackersBlockedOpen } = this.state
return (
<BlockedInfoRowDetails>
<BlockedInfoRowSummary onClick={this.onClickFakeThirdPartyTrackersBlocked}>
<BlockedInfoRowData disabled={false}>
{
dummyThirdPartyTrackersBlockedOpen
? <ArrowUpIcon />
: <ArrowDownIcon />
}
<BlockedInfoRowStats>{2}</BlockedInfoRowStats>
<BlockedInfoRowText>{getLocale('thirdPartyTrackersBlocked')}</BlockedInfoRowText>
</BlockedInfoRowData>
</BlockedInfoRowSummary>
<BlockedListStatic>
<StaticResourcesList list={dummyData.otherBlockedResources} />
</BlockedListStatic>
</BlockedInfoRowDetails>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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/. */

import * as React from 'react'

// Feature-specific components
import {
BlockedInfoRowSingleText,
BlockedInfoRowText
} from 'brave-ui/features/shields'

// Helpers
import { getLocale } from '../../../background/api/localeAPI'

export default class AdsTrackersControl extends React.PureComponent<{}, {}> {
render () {
return (
<BlockedInfoRowSingleText>
<BlockedInfoRowText>
<span>{getLocale('thirdPartyCookiesBlocked')}</span>
</BlockedInfoRowText>
</BlockedInfoRowSingleText>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* 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/. */

import * as React from 'react'

// Feature-specific components
import {
BlockedInfoRowDetails,
ArrowUpIcon,
ArrowDownIcon,
BlockedInfoRowStats,
BlockedInfoRowForSelectSummary,
BlockedInfoRowDataForSelect,
BlockedListStatic,
BlockedInfoRowText,
dummyData
} from 'brave-ui/features/shields'

// Group components
import StaticResourcesList from '../../shared/resourcesBlockedList/staticResourcesList'

// Helpers
import { getLocale } from '../../../background/api/localeAPI'

interface State {
dummyThirdPartyFingerprintingBlockedOpen: boolean
}

export default class AdsTrackersControl extends React.PureComponent<{}, State> {
constructor (props: {}) {
super(props)
this.state = { dummyThirdPartyFingerprintingBlockedOpen: false }
}

onClickFakeThirdPartyFingerprintingBlocked = () => {
this.setState({ dummyThirdPartyFingerprintingBlockedOpen: !this.state.dummyThirdPartyFingerprintingBlockedOpen })
}
render () {
const { dummyThirdPartyFingerprintingBlockedOpen } = this.state
return (
<BlockedInfoRowDetails>
<BlockedInfoRowForSelectSummary onClick={this.onClickFakeThirdPartyFingerprintingBlocked}>
<BlockedInfoRowDataForSelect disabled={false}>
{
dummyThirdPartyFingerprintingBlockedOpen
? <ArrowUpIcon />
: <ArrowDownIcon />
}
<BlockedInfoRowStats>{2}</BlockedInfoRowStats>
<BlockedInfoRowText>
<span>{getLocale('thirdPartyFingerprintingBlocked')}</span>
</BlockedInfoRowText>
</BlockedInfoRowDataForSelect>
</BlockedInfoRowForSelectSummary>
<BlockedListStatic>
<StaticResourcesList list={dummyData.otherBlockedResources} />
</BlockedListStatic>
</BlockedInfoRowDetails>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* 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/. */

import * as React from 'react'

// Feature-specific components
import {
BlockedInfoRowText,
BlockedInfoRowData,
BlockedInfoRowDetails,
BlockedInfoRowSummary,
ArrowUpIcon,
ArrowDownIcon,
BlockedInfoRowStats,
BlockedListStatic,
dummyData
} from 'brave-ui/features/shields'

// Group components
import StaticResourcesList from '../../shared/resourcesBlockedList/staticResourcesList'

// Helpers
import { getLocale } from '../../../background/api/localeAPI'

interface State {
dummyConnectionsUpgradedHTTPSOpen: boolean
}

export default class AdsTrackersControl extends React.PureComponent<{}, State> {
constructor (props: {}) {
super(props)
this.state = { dummyConnectionsUpgradedHTTPSOpen: false }
}

onClickFakeConnectionsUpgradedHTTPS = () => {
this.setState({ dummyConnectionsUpgradedHTTPSOpen: !this.state.dummyConnectionsUpgradedHTTPSOpen })
}

render () {
const { dummyConnectionsUpgradedHTTPSOpen } = this.state
return (
<BlockedInfoRowDetails>
<BlockedInfoRowSummary onClick={this.onClickFakeConnectionsUpgradedHTTPS}>
<BlockedInfoRowData disabled={false}>
{
dummyConnectionsUpgradedHTTPSOpen
? <ArrowUpIcon />
: <ArrowDownIcon />
}
<BlockedInfoRowStats>{2}</BlockedInfoRowStats>
<BlockedInfoRowText>{getLocale('connectionsUpgradedHTTPS')}</BlockedInfoRowText>
</BlockedInfoRowData>
</BlockedInfoRowSummary>
<BlockedListStatic>
<StaticResourcesList list={dummyData.otherBlockedResources} />
</BlockedListStatic>
</BlockedInfoRowDetails>
)
}
}
Loading

0 comments on commit 0c4c11f

Please sign in to comment.