Skip to content

Commit

Permalink
only show hostname of HTTPS upgrades in details view
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed May 28, 2019
1 parent a0b789d commit 420821f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
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 '../list/static'
import HTTPSUpgrades from '../list/httpsUpgrades'

// Locale
import { getLocale } from '../../background/api/localeAPI'
Expand Down Expand Up @@ -128,11 +128,10 @@ export default class HTTPSUpgradesControl extends React.PureComponent<Props, Sta
</BlockedInfoRow>
{
connectionsUpgradedOpen &&
<StaticList
<HTTPSUpgrades
favicon={favicon}
hostname={hostname}
stats={httpsRedirected}
name={getLocale('connectionsUpgradedHTTPS')}
list={httpsRedirectedResources}
onClose={this.onOpenConnectionsUpgradedToHTTPS}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* 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'

import {
BlockedListHeader,
BlockedListSummary,
BlockedListContent,
BlockedListStatic,
BlockedListItem,
BlockedListFooter,
ArrowUpIcon,
Favicon,
SiteInfoText,
BlockedInfoRowStats,
BlockedListSummaryText,
ShieldsButton
} from 'brave-ui/features/shields'

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

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

interface Props {
favicon: string
hostname: string
stats: number
list: Array<string>
onClose?: (event?: React.MouseEvent<any>) => void
}

export default class HTTPSUpgrades extends React.PureComponent<Props, {}> {
get statsDisplay (): string {
const { stats } = this.props
return blockedResourcesSize(stats)
}

getHostname = (url: string): string => {
return new window.URL(url).hostname
}

render () {
const { favicon, hostname, list, onClose } = this.props
return (
<BlockedListContent>
<BlockedListHeader>
<Favicon src={favicon} />
<SiteInfoText title={hostname}>{hostname}</SiteInfoText>
</BlockedListHeader>
<details open={true}>
<BlockedListSummary onClick={onClose}>
<ArrowUpIcon />
<BlockedInfoRowStats>{this.statsDisplay}</BlockedInfoRowStats>
<BlockedListSummaryText>{getLocale('connectionsUpgradedHTTPS')}</BlockedListSummaryText>
</BlockedListSummary>
<BlockedListStatic>
{list.map((item, index) => <BlockedListItem key={index}>{this.getHostname(item)}</BlockedListItem>)}
</BlockedListStatic>
</details>
<BlockedListFooter>
<ShieldsButton level='primary' type='accent' onClick={onClose} text={getLocale('goBack')} />
</BlockedListFooter>
</BlockedListContent>
)
}
}

0 comments on commit 420821f

Please sign in to comment.