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

Commit

Permalink
support open settings and reload actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Jul 24, 2018
1 parent 266ceff commit 6bed473
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/components/braveShields/braveShields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class BraveShields extends React.Component<BraveShieldsProps, {}>
allowScriptOriginsOnce={actions.allowScriptOriginsOnce}
changeNoScriptSettings={actions.changeNoScriptSettings}
/>
<BraveShieldsFooter />
<BraveShieldsFooter tabId={shieldsPanelTabData.id} />
</div>
)
}
Expand Down
37 changes: 30 additions & 7 deletions app/components/braveShields/braveShieldsFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,48 @@

import * as React from 'react'
import { Grid, Column } from 'brave-ui/gridSystem'
import Anchor from 'brave-ui/anchor'
import UnstyledButton from 'brave-ui/unstyledButton'
import { getMessage } from '../../background/api/localeAPI'
import theme from '../../theme'
import * as tabsAPI from '../../background/api/tabsAPI'

export interface BraveShieldsStatsProps {
tabId: number
}

export default class BraveShieldsFooter extends React.PureComponent<BraveShieldsStatsProps, {}> {
constructor (props: BraveShieldsStatsProps) {
super(props)
this.openSettings = this.openSettings.bind(this)
this.reloadShields = this.reloadShields.bind(this)
}

openSettings () {
tabsAPI.createTab({ url: 'chrome://settings' })
.catch((err) => console.log(err))
}

reloadShields () {
tabsAPI.reloadTab(this.props.tabId, true)
.catch((err) => console.log(err))
}

export default class BraveShieldsFooter extends React.PureComponent<{}, {}> {
render () {
return (
<Grid id='braveShieldsFooter' theme={theme.braveShieldsFooter}>
<Column size={9} theme={theme.columnStart}>
<Anchor
theme={theme.editLink}
href='chrome://settings'
target='_blank'
<UnstyledButton
theme={theme.noUserSelect}
onClick={this.openSettings}
text={getMessage('shieldsFooterEditDefault')}
/>
</Column>
<Column size={3} theme={theme.columnEnd}>
<UnstyledButton theme={theme.noUserSelect} text={getMessage('shieldsFooterReload')} />
<UnstyledButton
onClick={this.reloadShields}
theme={theme.noUserSelect}
text={getMessage('shieldsFooterReload')}
/>
</Column>
</Grid>
)
Expand Down

0 comments on commit 6bed473

Please sign in to comment.