-
Notifications
You must be signed in to change notification settings - Fork 869
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get region list from vpn service to webui
- Loading branch information
Showing
20 changed files
with
347 additions
and
128 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
7 changes: 7 additions & 0 deletions
7
components/brave_vpn/resources/panel/api/panel_browser_api.ts
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,7 @@ | ||
// Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
// 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/. | ||
|
||
// Provide access to all the generated types | ||
export * from 'gen/brave/components/brave_vpn/brave_vpn.mojom.m.js' |
10 changes: 10 additions & 0 deletions
10
components/brave_vpn/resources/panel/api/region_interface.ts
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,10 @@ | ||
export interface Region { | ||
continent: string | ||
name: string | ||
namePretty: string | ||
} | ||
export interface RegionState { | ||
all?: Array<Region>, | ||
current?: Region, | ||
hasError: boolean | ||
} |
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
75 changes: 75 additions & 0 deletions
75
components/brave_vpn/resources/panel/components/select-region-list/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,75 @@ | ||
import * as React from 'react' | ||
import * as S from './style' | ||
import { Button, Radio } from 'brave-ui' | ||
import { CaratStrongLeftIcon } from 'brave-ui/components/icons' | ||
import { Region } from '../../api/region_interface' | ||
import locale from '../../constants/locale' | ||
interface Props { | ||
onDone: Function | ||
onRegionClick: Function | ||
onConnectClick: Function | ||
regions: Array<Region> | ||
selectedRegion: Region | ||
} | ||
|
||
function SelectRegion (props: Props) { | ||
// TODO(nullhook): Scroll to the selected radio input when this component loads | ||
// TODO(nullhook): Add search region functionality | ||
const handleGoBackClick = () => { | ||
props.onDone() | ||
} | ||
|
||
const handleItemClick = (currentRegion: Region) => { | ||
props.onRegionClick(currentRegion) | ||
} | ||
|
||
const handleConnect = () => { | ||
props.onConnectClick() | ||
} | ||
|
||
return ( | ||
<S.Box> | ||
<S.PanelContent> | ||
<S.PanelHeader> | ||
<S.BackButton | ||
type='button' | ||
onClick={handleGoBackClick} | ||
> | ||
<CaratStrongLeftIcon /> | ||
</S.BackButton> | ||
</S.PanelHeader> | ||
<S.RegionList> | ||
<Radio | ||
value={{ [props.selectedRegion.name]: true }} | ||
size={'small'} | ||
disabled={false} | ||
> | ||
{props.regions.map((entry: Region, i: number) => ( | ||
<div | ||
key={i} | ||
data-value={entry.name} | ||
> | ||
<S.RegionLabel | ||
onClick={handleItemClick.bind(this, entry)} | ||
> | ||
{entry.namePretty} | ||
</S.RegionLabel> | ||
</div> | ||
))} | ||
</Radio> | ||
</S.RegionList> | ||
<S.ActionArea> | ||
<Button | ||
onClick={handleConnect} | ||
level='primary' | ||
type='accent' | ||
brand='rewards' | ||
text={locale.connectLabel} | ||
/> | ||
</S.ActionArea> | ||
</S.PanelContent> | ||
</S.Box> | ||
) | ||
} | ||
|
||
export default SelectRegion |
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
61 changes: 0 additions & 61 deletions
61
components/brave_vpn/resources/panel/components/select-region/index.tsx
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
components/brave_vpn/resources/panel/components/status-indicator/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
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.