-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2529 from brave/ca-3367
only show hostname of HTTPS upgrades in details view
- Loading branch information
Showing
2 changed files
with
72 additions
and
3 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
70 changes: 70 additions & 0 deletions
70
components/brave_extension/extension/brave_extension/components/list/httpsUpgrades.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,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> | ||
) | ||
} | ||
} |