Skip to content

Commit

Permalink
move current shields under advancedView
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Jul 5, 2019
1 parent 2cefd35 commit 260da4d
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
} from 'brave-ui/features/shields'

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

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

// Helpers
import {
Expand All @@ -29,11 +29,11 @@ import {
getTabIndexValueBasedOnProps,
blockedResourcesSize,
maybeDisableResourcesRow
} from '../../helpers/shieldsUtils'
} from '../../../helpers/shieldsUtils'

// Types
import { BlockAdsTrackers } from '../../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../types/other/blockTypes'
import { BlockAdsTrackers } from '../../../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../../types/other/blockTypes'

interface CommonProps {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import * as React from 'react'
import { BlockedInfoRowSingle, SelectBox } from 'brave-ui/features/shields'

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

// Types
import { BlockCookies } from '../../types/actions/shieldsPanelActions'
import { BlockCookiesOptions } from '../../types/other/blockTypes'
import { BlockCookies } from '../../../types/actions/shieldsPanelActions'
import { BlockCookiesOptions } from '../../../types/other/blockTypes'

export interface Props {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import {
} from 'brave-ui/features/shields'

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

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

// Helpers
import {
maybeDisableResourcesRow,
getTabIndexValueBasedOnProps,
blockedResourcesSize
} from '../../helpers/shieldsUtils'
} from '../../../helpers/shieldsUtils'

// Types
import { BlockFingerprinting } from '../../types/actions/shieldsPanelActions'
import { BlockFPOptions } from '../../types/other/blockTypes'
import { BlockFingerprinting } from '../../../types/actions/shieldsPanelActions'
import { BlockFPOptions } from '../../../types/other/blockTypes'

interface CommonProps {
favicon: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
} from 'brave-ui/features/shields'

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

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

// Helpers
import {
Expand All @@ -27,11 +27,11 @@ import {
getTabIndexValueBasedOnProps,
blockedResourcesSize,
getToggleStateViaEventTarget
} from '../../helpers/shieldsUtils'
} from '../../../helpers/shieldsUtils'

// Types
import { HttpsEverywhereToggled } from '../../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../types/other/blockTypes'
import { HttpsEverywhereToggled } from '../../../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../../types/other/blockTypes'

interface CommonProps {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
} from 'brave-ui/features/shields'

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

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

// Helpers
import {
Expand All @@ -28,19 +28,19 @@ import {
maybeBlockResource,
getTabIndexValueBasedOnProps,
getToggleStateViaEventTarget
} from '../../helpers/shieldsUtils'
} from '../../../helpers/shieldsUtils'

// Types
import { BlockJSOptions } from '../../types/other/blockTypes'
import { NoScriptInfo } from '../../types/other/noScriptInfo'
import { BlockJSOptions } from '../../../types/other/blockTypes'
import { NoScriptInfo } from '../../../types/other/noScriptInfo'
import {
BlockJavaScript,
AllowScriptOriginsOnce,
SetScriptBlockedCurrentState,
SetGroupedScriptsBlockedCurrentState,
SetAllScriptsBlockedCurrentState,
SetFinalScriptsBlockedState
} from '../../types/actions/shieldsPanelActions'
} from '../../../types/actions/shieldsPanelActions'

interface CommonProps {
// Global props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import * as React from 'react'
import { MainFooter, Link } from 'brave-ui/features/shields'

// API
import * as tabsAPI from '../background/api/tabsAPI'
import * as tabsAPI from '../../background/api/tabsAPI'

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

export interface Props {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import {
} from 'brave-ui/features/shields'

// Locale
import { getLocale } from '../background/api/localeAPI'
import { getLocale } from '../../background/api/localeAPI'
import {
blockedResourcesSize,
getTotalBlockedSizeStrings,
getToggleStateViaEventTarget
} from '../helpers/shieldsUtils'
} from '../../helpers/shieldsUtils'

// Types
import { BlockOptions } from '../types/other/blockTypes'
import { ShieldsToggled } from '../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../types/other/blockTypes'
import { ShieldsToggled } from '../../types/actions/shieldsPanelActions'

interface CommonProps {
enabled: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* 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'

// CSS normalizer
import 'emptykit.css'

// Feature-specific components
import { ShieldsPanel } from 'brave-ui/features/shields'

// Components group
import Header from './header'
import InterfaceControls from './interfaceControls'
import PrivacyControls from './privacyControls'
import Footer from './footer'

// Types
import { Tab, PersistentData } from '../../types/state/shieldsPannelState'
import { isShieldsEnabled, getFavicon } from '../../helpers/shieldsUtils'
import {
ShieldsToggled,
BlockAdsTrackers,
HttpsEverywhereToggled,
BlockJavaScript,
BlockFingerprinting,
BlockCookies,
AllowScriptOriginsOnce,
SetScriptBlockedCurrentState,
SetGroupedScriptsBlockedCurrentState,
SetAllScriptsBlockedCurrentState,
SetFinalScriptsBlockedState,
SetAdvancedViewFirstAccess
} from '../../types/actions/shieldsPanelActions'

interface Props {
actions: {
shieldsToggled: ShieldsToggled
blockAdsTrackers: BlockAdsTrackers
httpsEverywhereToggled: HttpsEverywhereToggled
blockJavaScript: BlockJavaScript
blockFingerprinting: BlockFingerprinting
blockCookies: BlockCookies
allowScriptOriginsOnce: AllowScriptOriginsOnce
setScriptBlockedCurrentState: SetScriptBlockedCurrentState
setGroupedScriptsBlockedCurrentState: SetGroupedScriptsBlockedCurrentState
setAllScriptsBlockedCurrentState: SetAllScriptsBlockedCurrentState
setFinalScriptsBlockedState: SetFinalScriptsBlockedState
setAdvancedViewFirstAccess: SetAdvancedViewFirstAccess
}
shieldsPanelTabData: Tab
persistentData: PersistentData
}

interface State {
isBlockedListOpen: boolean
}

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

get favicon (): string {
const { url } = this.props.shieldsPanelTabData
return getFavicon(url)
}

get isShieldsEnabled (): boolean {
const { braveShields } = this.props.shieldsPanelTabData
return isShieldsEnabled(braveShields)
}

setBlockedListOpen = () => {
this.setState({ isBlockedListOpen: !this.state.isBlockedListOpen })
}

render () {
const { shieldsPanelTabData, actions } = this.props
const { isBlockedListOpen } = this.state

if (!shieldsPanelTabData) {
return null
}

return (
<ShieldsPanel data-test-id='brave-shields-panel' style={{ width: '370px' }}>
<Header
enabled={this.isShieldsEnabled}
favicon={this.favicon}
origin={origin}
hostname={shieldsPanelTabData.hostname}
isBlockedListOpen={isBlockedListOpen}
adsBlocked={shieldsPanelTabData.adsBlocked}
trackersBlocked={shieldsPanelTabData.trackersBlocked}
httpsUpgrades={shieldsPanelTabData.httpsRedirected}
scriptsBlocked={shieldsPanelTabData.javascriptBlocked}
fingerprintingBlocked={shieldsPanelTabData.fingerprintingBlocked}
shieldsToggled={actions.shieldsToggled}
/>
{
this.isShieldsEnabled && (
<>
<InterfaceControls
// Global props
isBlockedListOpen={isBlockedListOpen}
setBlockedListOpen={this.setBlockedListOpen}
hostname={shieldsPanelTabData.hostname}
favicon={this.favicon}
// Ads/Trackers
ads={shieldsPanelTabData.ads}
adsBlocked={shieldsPanelTabData.adsBlocked}
adsBlockedResources={shieldsPanelTabData.adsBlockedResources}
trackers={shieldsPanelTabData.trackers}
trackersBlocked={shieldsPanelTabData.trackersBlocked}
trackersBlockedResources={shieldsPanelTabData.trackersBlockedResources}
blockAdsTrackers={actions.blockAdsTrackers}
// HTTPS Upgrades
httpsRedirected={shieldsPanelTabData.httpsRedirected}
httpUpgradableResources={shieldsPanelTabData.httpUpgradableResources}
httpsRedirectedResources={shieldsPanelTabData.httpsRedirectedResources}
httpsEverywhereToggled={actions.httpsEverywhereToggled}
/>
<PrivacyControls
// Global props
isBlockedListOpen={isBlockedListOpen}
setBlockedListOpen={this.setBlockedListOpen}
hostname={shieldsPanelTabData.hostname}
favicon={this.favicon}
// JavaScript
javascript={shieldsPanelTabData.javascript}
javascriptBlocked={shieldsPanelTabData.javascriptBlocked}
noScriptInfo={shieldsPanelTabData.noScriptInfo}
blockJavaScript={actions.blockJavaScript}
allowScriptOriginsOnce={actions.allowScriptOriginsOnce}
setScriptBlockedCurrentState={actions.setScriptBlockedCurrentState}
setGroupedScriptsBlockedCurrentState={actions.setGroupedScriptsBlockedCurrentState}
setAllScriptsBlockedCurrentState={actions.setAllScriptsBlockedCurrentState}
setFinalScriptsBlockedState={actions.setFinalScriptsBlockedState}
// Cookies
blockCookies={actions.blockCookies}
cookies={shieldsPanelTabData.cookies}
// Fingerprinting
fingerprinting={shieldsPanelTabData.fingerprinting}
fingerprintingBlocked={shieldsPanelTabData.fingerprintingBlocked}
fingerprintingBlockedResources={shieldsPanelTabData.fingerprintingBlockedResources}
blockFingerprinting={actions.blockFingerprinting}
/>
</>
)
}
<Footer isBlockedListOpen={isBlockedListOpen} />
</ShieldsPanel>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import AdsTrackersControl from './controls/adsTrackersControl'
import HTTPSUpgradesControl from './controls/httpsUpgradesControl'

// Types
import { BlockAdsTrackers, HttpsEverywhereToggled } from '../types/actions/shieldsPanelActions'
import { BlockOptions } from '../types/other/blockTypes'
import { BlockAdsTrackers, HttpsEverywhereToggled } from '../../types/actions/shieldsPanelActions'
import { BlockOptions } from '../../types/other/blockTypes'

interface CommonProps {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import {
} from 'brave-ui/features/shields'

// Helpers
import { blockedResourcesSize } from '../../helpers/shieldsUtils'
import { blockedResourcesSize } from '../../../helpers/shieldsUtils'

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

interface Props {
favicon: string
Expand Down Expand Up @@ -57,7 +57,7 @@ export default class HTTPSUpgrades extends React.PureComponent<Props, {}> {
<BlockedInfoRowStats>{this.statsDisplay}</BlockedInfoRowStats>
<BlockedListSummaryText>{getLocale('connectionsUpgradedHTTPS')}</BlockedListSummaryText>
</BlockedListSummary>
<BlockedListStatic>
<BlockedListStatic fixedHeight={true}>
{list.map((item, index) => <BlockedListItem key={index}>{this.getHostname(item)}</BlockedListItem>)}
</BlockedListStatic>
</details>
Expand Down
Loading

0 comments on commit 260da4d

Please sign in to comment.