Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only show hostname of HTTPS upgrades in details view #2529

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
)
}
}