Skip to content

Commit

Permalink
feat(wallet): Enable Panel V2 by Default
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglashdaniel committed Aug 21, 2023
1 parent e474398 commit 7172da0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
26 changes: 22 additions & 4 deletions browser/ui/webui/brave_wallet/wallet_panel_ui_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ std::string NeonEVMNetworkChainName() {
return NeonEVMNetwork() + " .chainName";
}

std::string DAppSettingsButton() {
return R"([data-test-id='dapp-settings-button'])";
}

std::string NetworksButton() {
return R"([data-test-id='select-network-button'])";
}
Expand Down Expand Up @@ -108,11 +112,16 @@ bool WaitFor(content::WebContents* web_contents, const std::string& selector) {

bool WaitAndClickElement(content::WebContents* web_contents,
const std::string& selector) {
if (!WaitFor(web_contents, selector)) {
return false;
for (int i = 0; i < 10; ++i) {
if (!WaitFor(web_contents, selector)) {
return false;
}
auto result = EvalJs(web_contents, selector + ".click()");
if (result.value.is_none() && result.error.empty()) {
return true;
}
}

return EvalJs(web_contents, selector + ".click()").value.is_none();
return false;
}

} // namespace
Expand Down Expand Up @@ -248,6 +257,9 @@ IN_PROC_BROWSER_TEST_F(WalletPanelUIBrowserTest, InitialUIRendered) {
#endif
IN_PROC_BROWSER_TEST_F(WalletPanelUIBrowserTest, MAYBE_HideNetworkInSettings) {
ActivateWalletTab();
// Wait and click on DApp settings button.
ASSERT_TRUE(
WaitAndClickElement(wallet(), QuerySelectorJS(DAppSettingsButton())));
// Wait and click on select network button.
ASSERT_TRUE(WaitAndClickElement(wallet(), QuerySelectorJS(NetworksButton())));

Expand All @@ -266,6 +278,9 @@ IN_PROC_BROWSER_TEST_F(WalletPanelUIBrowserTest, MAYBE_HideNetworkInSettings) {

ActivateWalletTab();
wallet()->GetController().Reload(content::ReloadType::NORMAL, true);
// Wait and click on DApp settings button.
ASSERT_TRUE(
WaitAndClickElement(wallet(), QuerySelectorJS(DAppSettingsButton())));
// Wait and click on select network button.
ASSERT_TRUE(WaitAndClickElement(wallet(), QuerySelectorJS(NetworksButton())));

Expand All @@ -281,6 +296,9 @@ IN_PROC_BROWSER_TEST_F(WalletPanelUIBrowserTest, CustomNetworkInSettings) {
CreateSettingsTab();

ActivateWalletTab();
// Wait and click on DApp settings button.
ASSERT_TRUE(
WaitAndClickElement(wallet(), QuerySelectorJS(DAppSettingsButton())));
// Wait and click on select network button.
ASSERT_TRUE(WaitAndClickElement(wallet(), QuerySelectorJS(NetworksButton())));

Expand Down
2 changes: 1 addition & 1 deletion components/brave_wallet/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ BASE_FEATURE(kBraveWalletNftPinningFeature,

BASE_FEATURE(kBraveWalletPanelV2Feature,
"BraveWalletPanelV2",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kBraveWalletBitcoinFeature,
"BraveWalletBitcoin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
// Styled Components
import {
NetworkButton,
NameText,
NetworkName,
ActiveIndicator
} from './dapp-connection-settings.style'
import {
Expand Down Expand Up @@ -55,6 +55,7 @@ export const ChangeNetworkButton = (props: Props) => {
return (
<NetworkButton
onClick={onClick}
data-test-chain-id={'chain-' + network.chainId}
>
<Row
width='unset'
Expand All @@ -64,12 +65,9 @@ export const ChangeNetworkButton = (props: Props) => {
marginRight={8}
size='big'
/>
<NameText
textSize='14px'
isBold={false}
>
<NetworkName>
{network.chainName}
</NameText>
</NetworkName>
</Row>
{selectedNetwork?.chainId === network.chainId &&
<ActiveIndicator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export const DAppConnectionMain = (props: Props) => {
<VerticalSpace space='8px' />
<SectionButton
onClick={() => onSelectOption('networks')}
data-test-id='select-network-button'
>
<Row
width='unset'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const SettingsButton = styled(WalletButton)`
margin-right: 16px;
background-color: transparent;
position: relative;
z-index: 10;
`

export const ConnectedIcon = styled(Icon) <{
Expand All @@ -47,6 +48,16 @@ export const ConnectedText = styled(Text) <{
line-height: 24px;
`

export const OverlapForClick = styled.div`
display: flex;
position: fixed;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
z-index: 11;
`

export const SettingsBubbleWrapper = styled.div`
display: flex;
align-items: flex-end;
Expand Down Expand Up @@ -152,6 +163,18 @@ export const NameText = styled(Text)`
text-align: left;
`

export const NetworkName = styled.span`
font-family: 'Poppins';
color: ${leo.color.text.primary};
line-height: 24px;
word-wrap: wrap;
word-break: break-all;
text-align: left;
font-size: 14px;
font-weight: 400;
letter-spacing: 0.02em;
`

export const DescriptionText = styled(Text)`
color: ${leo.color.text.secondary};
line-height: 18px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ import {
PointerShadow,
BackgroundBlur,
FavIcon,
NetworkIconWrapper
NetworkIconWrapper,
OverlapForClick
} from './dapp-connection-settings.style'

export type DAppConnectionOptionsType =
Expand Down Expand Up @@ -295,7 +296,8 @@ export const DAppConnectionSettings = () => {
return (
<>
<SettingsButton
onMouseDown={() => setShowSettings(prev => !prev)}
onClick={() => setShowSettings(prev => !prev)}
data-test-id='dapp-settings-button'
>
<ConnectedIcon
name={
Expand All @@ -321,6 +323,7 @@ export const DAppConnectionSettings = () => {
</SettingsButton>
{showSettings &&
<>
<OverlapForClick />
<SettingsBubbleWrapper>
<Pointer />
<PointerShadow />
Expand Down

0 comments on commit 7172da0

Please sign in to comment.