-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move current shields under advancedView
- Loading branch information
1 parent
2cefd35
commit 260da4d
Showing
22 changed files
with
239 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
158 changes: 158 additions & 0 deletions
158
components/brave_extension/extension/brave_extension/components/advancedView/index.tsx
This file contains 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,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> | ||
) | ||
} | ||
} |
This file contains 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 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.